Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

To get the url of the next page

26 views
Skip to first unread message

Sugandha Agarwal

unread,
Aug 30, 2019, 5:07:55 AM8/30/19
to Selenium Users
Hi All

If I have a page 1 known as login page and I am navigating to page 2 after logging in the same tab. The new tab is not opened. How can I capture the URL of the new page? 

Whenever I try to take capture the Url of page 2, the system prints URL of page 1 due to which I am unable to perform my next actions.

getCurrentURL() is not capturing the URL of page 2. I am redirected to page 2 but still, it prints the URL of page 1. 

Please, help how can I resolve this issue. 

Regards
Sugandha

chetan baraskar

unread,
Aug 30, 2019, 5:14:20 AM8/30/19
to seleniu...@googlegroups.com
Hi,

You need to switch to the second tab, so collect the window id of tab and switch to particular window accordingly like below
This is C# code, similar logic you can write in java

public void switchToBrowserTab()
{
Thread.Sleep(3000);

String parentWindow = driver.CurrentWindowHandle;

List<String> allwindows = driver.WindowHandles.ToList();
foreach (var child in allwindows)
{
if (!parentWindow.Equals(child))
{
driver.SwitchTo().Window(child);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);


}
}


}


Disclaimer: This e-mail & attachment(s) within it are for sole use of intended recipient(s) & may contain confidential & privileged information. If you are not the intended recipient, please intimate the sender by replying to this email & destroy all copies & the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited & unlawful. The recipient acknowledges that COMPANY , its subsidiaries, associated companies or persons authorized by it (collectively "THE Group"), are unable to exercise control, ensure, guarantee the integrity of/over the contents of the information contained in e-mail transmissions & further acknowledges that any views expressed in this message are those of the individual sender & no binding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of THE Group.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7d90ffb0-1251-414e-ac6c-1d576a9a5d77%40googlegroups.com.


--
Have a Nice Day
Chetan
Reply all
Reply to author
Forward
0 new messages