selenium webdriver close popup

50 views
Skip to first unread message

Muhammad Molla

unread,
Apr 7, 2015, 10:55:21 AM4/7/15
to seleniu...@googlegroups.com
Any Body have please help me how  to solve 'selenium webdriver close popup' 
I sow many way in google but i cant ,
May be its very easy question .

Thanks
Arif

CH!NN@ K

unread,
Apr 11, 2015, 10:39:16 AM4/11/15
to seleniu...@googlegroups.com

Handle alert & Handle alert conformation :-


We have to navigateto Alert or Confirmation windows

driver.switchTo().alert();                                                  

To click on "OK"  or "Cancel" on Alertor Confirmation 

driver.switchTo().alert().accept();—ToclickOK
                
driver.switchTo().alert().dismiss();—ToclickCancel         

Example :-

@Test
public void Entertext()throws Exception {
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@id='node-223']/div/div[1]/div/div/button")).click();
Alert alert = driver.switchTo().alert();
alert.sendKeys("The value that you wish to enter");
alert.accept();
}    



Below approach to handle Dynamically changing popup windows :-

Set<String> window1= driver.getWindowHandles();
Object s[]=window1.toArray();
driver.switchTo().window(s[1].toString());

Handle multiple popups windows

driver.getWindowHandles();

                                                      

---
Thanks & Regards,
Purushotham Karimbedu,
Drupal Developer and QA Engineer,
Website for Selenium : http://techlearn.in


--
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 post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/dbf5f72f-9150-4577-a238-af963814d596%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

murali seleniumtrainer

unread,
Apr 11, 2015, 10:55:39 PM4/11/15
to seleniu...@googlegroups.com
Hi,

First cross check is it Alert or window..

if it is Alert, then use alert commands.. like switch to alerts..accept or dismiss as per your requirement..

if it is window, then go for windowHandles, to switch in between windows and close required one..

let me know, if above once are not worked in your case..

Murali
Reply all
Reply to author
Forward
0 new messages