Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I am having trouble clicking or interacting with some page elements. They seem like normal DOM objects. just buttons here is the code for one

<div style="clear: both; text-align: right">

 <img id="nextstep" class="nextbtn" height="21" alt="" src="/edit/images/author/next.png">

</div>

After clicking a button as "Upload file" another pop-up window was opened. My task is to upload a file at the pop-up window and back to the original window. I'll try to explain

I start a webDriver for

www.test.com (<- made up name for example)

I logged in

Click upload a file button

After this click, our site redirects to www.foo.com instead of the above I am using the same driver created earlier and I try to interact with the buttons on the post upload page

button.click()

It never finds these buttons but they are there in firebug and appear normal.

1 Answer

0 votes
by (62.9k points)

You may try to switch to the window again after the redirect. Save your window handle:

String myWindowHandle = driver.getWindowHandle();

redirect to the page you want and then call switchTo using the window handle:

driver.switchTo().window(myWindowHandle );

DIf your page contains any frame,It may be possible that you are not in the correct frame after the redirect.

Browse Categories

...