how to handle modal dialog box in Selenium

18,356 views
Skip to first unread message

Danish Khan

unread,
Sep 24, 2012, 5:32:52 AM9/24/12
to seleniu...@googlegroups.com
Hi All,

  There is a scenario where i get the modal dialog box when i hit the URL.
  I am not being able to handle this scenario because "webdriver" is not getting access to the dialog box. Is there a way to handle this. 


Regards,
 Danish

   

Manoj Hans

unread,
Sep 24, 2012, 7:11:49 AM9/24/12
to seleniu...@googlegroups.com
try this...

Alert alt=driver.switchTo().alert();
   System.out.println(alt.getText());
   alt.accept();


--Manoj Hans

sateesh babu

unread,
Sep 24, 2012, 11:03:02 AM9/24/12
to seleniu...@googlegroups.com
Hi

Try this

driver.switchTo().alert().accept();


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/UB8GBvzrQDEJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
SATEESH BABU.K

Danish Khan

unread,
Sep 25, 2012, 3:44:21 AM9/25/12
to seleniu...@googlegroups.com
Thanks Sateesh.

Danish Khan

unread,
Sep 25, 2012, 3:46:06 AM9/25/12
to seleniu...@googlegroups.com
Thanks Manoj, it worked. i am doing it in python and it is handling "modal dialog" now.

import time
from selenium import webdriver
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()

driver.switch_to_alert().accept()
time.sleep(5)
driver.close()

Thanks,
 Danish

Neeraj Sharma

unread,
Sep 25, 2012, 3:47:42 AM9/25/12
to seleniu...@googlegroups.com

hi, All the solutions are same as provided by Manoj and Satesh. The main solution behind this is that you have to explore more about Action class.

Neeraj Sharma

unread,
Sep 25, 2012, 3:49:46 AM9/25/12
to seleniu...@googlegroups.com
Danish these are not the modal dialog windows,, these are java script alerts:)

sateesh babu

unread,
Sep 25, 2012, 8:05:04 AM9/25/12
to seleniu...@googlegroups.com
Hi Danish,

i tried like this to handle alert.

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;


public class test1 {

    /**
     * @param args
     * @throws InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        WebDriver driver= new FirefoxDriver();
        driver.navigate().to("http://www.agoda.com/?ymsg=1");
        Thread.sleep(3000L);
        driver.switchTo().alert().accept();
        System.out.println("Transaction Completed Successfully");
        driver.close();
   
    }

}



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/PRhP-rDCp-0J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
SATEESH BABU.K

Danish Khan

unread,
Oct 16, 2012, 5:16:00 AM10/16/12
to seleniu...@googlegroups.com
Thanks Sateesh, issue is resolved.

Venkata Karthik

unread,
Jan 9, 2015, 1:17:10 AM1/9/15
to seleniu...@googlegroups.com

Hi Friends,

Can some one please help me how do I handle authentication dialogs in Firefox, when I click on login button in a particular machine[accessing through firefox] I get a authentication dialog as given below.
I am using python with Selenium. Please give me answers in python.

Thanks in Advance.

Authentication dialog looks like this

Selenium Framework

unread,
Jan 11, 2015, 10:08:00 PM1/11/15
to seleniu...@googlegroups.com
Authentication pop ups are of multiple types based on the network authentication. There is HTTP basic, NTLM/CNTLM.

You will have to use a combination of browser preferences and external plugins. Here is an article that explains it all for you. Btw, please post a new thread if you are deviating from the main topic of the thread in future.


Cheers,
Reply all
Reply to author
Forward
0 new messages