How do you handle clicks on overlays when using selenium web driver

16,948 views
Skip to first unread message

Manisha

unread,
Sep 1, 2011, 2:57:00 PM9/1/11
to webdriver
Hi all,
I am using Selenium Web Driver 2.5 and was wondering how exactly do
we go about handling overlays when using the Selenium Web Driver 2.5?
I have the code where in I enter a value in an element, but once the
overlay comes up I am not certain on how to get a handle to the
overlay and how to reference the elements in the overlay.

I tried doing getWindowHandles(), but it always returns a handle to
one window and the value is alphanumeric value so I uncertain how to
go about from there.

WebElement query = driver.findElement(By.name("zip"));
query.sendKeys("94040");
query.submit();
Set<String> firstWindow = driver.getWindowHandles();


Any tips on how to do this will be helpful.

Best regards,

Manisha

Luke Inman-Semerau

unread,
Sep 1, 2011, 3:10:53 PM9/1/11
to webd...@googlegroups.com
It really depends on your page. If it's an overlay that is inside your window, then you should be able to just use driver.findElement  to interact. If that doesn't work, it probably means the overlay is using an iframe. Use an inspector tool (firebug or chrome) to see if that is true, if so, then you'll have to switchTo().frame(...)


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


Manisha

unread,
Sep 2, 2011, 1:54:09 AM9/2/11
to webd...@googlegroups.com
Thanks Luke.  Once I close the overlay how to I reference the parent window again.  I need to get to a dive in the main window.  Any tips appreciated.

Best,
Monisha

Manisha

unread,
Sep 2, 2011, 3:19:24 PM9/2/11
to webd...@googlegroups.com
HI all,
  I have a YUI panel that I want to close.  Getting a handle to the close link on the button and then calling the click event on that does not work.

driver.switchTo().defaultContent();
        WebElement closeLink = driver.findElement(By.id("lc_SPUL_TRANSITION_CLOSE"));
        closeLink.click();
        WebElement closeBtn = driver.findElement(By.id("lc_SPUL_TRANSITION_BUTTON"));        
        closeBtn.click();

It gives no errors but the panel does not close.  Any tips on resolving this will be much appreciated.

Thanks,
Manisha

Luke Inman-Semerau

unread,
Sep 2, 2011, 3:53:53 PM9/2/11
to webd...@googlegroups.com
If you can provide a link to the page or a similar page that has this we can help.

Manisha

--

Manisha

unread,
Sep 3, 2011, 12:10:30 PM9/3/11
to webd...@googlegroups.com
The site is www.walmart.com/ip/2034416 --> enter the zip Store pick up link select a store from the overlay and then a confirmation overlay comes up.  I am wondering how to close the third overlay.


Thanks for your help.

Best,
Manisha

Luke Inman-Semerau

unread,
Sep 3, 2011, 5:51:09 PM9/3/11
to webd...@googlegroups.com
So, that is inside of an iframe and then back to the main content... here's how you could do it (I didn't test this code...)

WebElement query = driver.findElement(By.name("zip"));
query.sendKeys("94040");
query.submit();
driver.switchTo().frame(driver.findElement(By.id("overlay")));
driver.findElement(By.cssSelector("div#STORE_MAKEMY_0 a")).click();
driver.switchTo().defaultContent();
driver.findElement(By.id("lc_TRANSITION_CLOSE")).click();


Almost didn't answer this because I'm diabolically opposed to walmart ;)

Manisha

unread,
Sep 6, 2011, 1:52:40 PM9/6/11
to webd...@googlegroups.com
Aren't we all opposed to it ..  Thanks!  I had the exact same thing however the final overlay / div does not close for some reason.  Will check further on this.

>>>> To unsubscribe from this group, send email to webdriver+...@googlegroups.com <webdriver%2Bunsu...@googlegroups.com>.

>>>> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "webdriver" group.
>>> To post to this group, send email to webd...@googlegroups.com.
>>> To unsubscribe from this group, send email to webdriver+...@googlegroups.com <webdriver%2Bunsu...@googlegroups.com>.

>>> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "webdriver" group.
>> To post to this group, send email to webd...@googlegroups.com.
>> To unsubscribe from this group, send email to webdriver+...@googlegroups.com <webdriver%2Bunsu...@googlegroups.com>.

>> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com <webdriver%2Bunsu...@googlegroups.com>.

Pratibha S

unread,
Mar 25, 2017, 8:31:09 PM3/25/17
to webdriver
Hi, I am having similar issue, some screenshots below:

1) first screen when overlay is not visible


2) I click on the "FLOWER 2" bar and the edit-pane slides in which is part of the overlay, and overlay covers the entire screen as below





3) Now want to come out of the edit-pane which is accomplished manually by clicking on the left side of the edit pane, i.e. the part where it still shows the previous screen (Flower 2). But using selenium, trying to click on the left side clicks on the overlay, could not close this overlay. Any help is appreciated.


Thanks,
Pratibha
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3
Reply all
Reply to author
Forward
0 new messages