Hey there! any question in your mind? Ask It Now!.

Popular Categories

How can i change focus to a new popup in Selenium?

+7 votes
asked in Software Testing by Jens

I'm using Selenium and Firefox.

I have a link on a page (say linkA) that opens a new page in a new tab. The new tab is displayed when linkA is clicked. I then want to interact with the new page

Selenium cannot identify the new tab. It reports:

[warn] Link has target '_blank', which is not supported in Selenium! Randomizing target to be: selenium_blank24003

Is there any way to tell Selenium to interact with the displayed tab?

2 Answers

0 votes
answered by seleniumGuru Expert (4,570 points)

you can try this

Webdriver driver = new FirefoxDriver();

driver .switchTo.window("Window name here"); \\by this you can go to new window 

you have to use this  code when your script opens a new window after click on that link ,

now you are in new window and can access the elements of new window.

0 votes
answered by yakup yazıcı
edited by Bhartesh

You can use switchTo() function in webdriver to switch other page or frame.

You can use index to switch.This int is a 0 based index of the windows available. The first window would be 0, the second 1 and so on.

It may help you!

Related Questions

+2 votes
1 answer 1,366 views
+1 vote
1 answer 588 views
+1 vote
1 answer 2,317 views
+5 votes
7 answers 14,776 views
+2 votes
1 answer 159 views
+2 votes
2 answers 872 views

Not a Member yet?

Ask to Folks Login

My Account
517 Folks are online
5 members and 512 guest online
Your feedback is highly appreciated