Selenium Webdriver and Modal Panels

459 views
Skip to first unread message

Luiz Gustavo Schroeder Vieira

unread,
Sep 12, 2011, 11:48:15 AM9/12/11
to selenium-...@googlegroups.com

Hi guys,


I cannot use .sendKeys("") to a textfield (inside a Modal Panel).

Check my code:
        // Configuring Firefox to run with no proxy
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        Proxy proxy = new Proxy();
        proxy.setNoProxy("http://homologacao.trt12.jus.br/");
        cap.setCapability(CapabilityType.PROXY, proxy);
        WebDriver driver = new FirefoxDriver(cap);
       
        // Managing 20 seconds timeouts
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
       
        // Get to the URL
        driver.get("http://homologacao.trt12.jus.br/proad");
       
        // Mapped the screen fields
        WebElement login = driver.findElement(By.id("username"));
        WebElement password = driver.findElement(By.id("password"));
        WebElement submit = driver.findElement(By.cssSelector("input.formSubmit"));
       
        // Login//Password - Enter
        login.sendKeys("PROAD2");
        password.sendKeys("proad2");
        submit.click();
       
        // Browsing to the CreateMinuta screen
        driver.findElement(By.linkText("Estou tratando")).click();
        driver.findElement(By.xpath("//td[@id='coluna11TabInterna']/table/tbody/tr[8]/td")).click();
        driver.findElement(By.xpath("//span[@id='corpo:formulario:barraAcoes']/fieldset/div/div[2]/img")).click();

        // CreateMinuta screen
        System.out.println("Arrives in the screen CreateMinuta!");
       
        WebElement modalPanel = driver.findElement(By.id("corpo:formulario:painelGenericoContainer"));
        System.out.println("Mapped the modal panel!");
       
        modalPanel.click();
        System.out.println("Clicked in the modal panel!");
       
        WebElement dsArquivo = modalPanel.findElement(By.xpath("//*[@id='corpo:formulario:dsArquivo']"));
        System.out.println("Mapped the field DsArquivo!");
               
        dsArquivo.isDisplayed();
        dsArquivo.isEnabled();
//       
        System.out.println("the field exists!!");

        String teste = "teste123";
        dsArquivo.sendKeys(teste);
        System.out.println("the text was insert!!");

Check the console:
Arrives in the screen CreateMinuta!
Mapped the modal panel!
Clicked in the modal panel!
Mapped the field DsArquivo!
the field exists!!
Exception in thread "main" org.openqa.selenium.WebDriverException: org.apache.http.NoHttpResponseException: The target server failed to respond
Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:30:44'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:406)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:191)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:49)
    at org.openqa.selenium.example.Script_003.runTest003(Script_003.java:73)
    at org.openqa.selenium.example.Script_003.main(Script_003.java:117)
Caused by: org.apache.http.NoHttpResponseException: The target server failed to respond
    at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:101)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)


How can I use .sendKeys inside a Modal Panel? Does anyone can help me?

Rakesh Prabhakaran

unread,
Sep 12, 2011, 11:54:35 AM9/12/11
to selenium-...@googlegroups.com
Try to get the url of the modal window and open it in a new browser window, you would be able to locate the element once control gets in the new window.
Hope this helps,

Regards,
Rakesh.P

--
You received this message because you are subscribed to the Google Groups "Selenium - Automated Software Testing" group.
To post to this group, send email to selenium-...@googlegroups.com.
To unsubscribe from this group, send email to selenium-test-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-test-tool?hl=en.

Luiz Gustavo Schroeder Vieira

unread,
Sep 12, 2011, 12:15:30 PM9/12/11
to selenium-...@googlegroups.com
I did that and displays the following error message:

Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with

Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:30:44'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)

2011/9/12 Rakesh Prabhakaran <rakesh.1...@gmail.com>



--
Atenciosamente,
Luiz Gustavo Schroeder Vieira, FCE, CTAL-TA
Consultor de Testes
BSTQB TAG Member
+55 (48) 9994-3569
Skype: luizgsvieira
luizgustavo@LUGATI.com.br
http://testavo.blogspot.com
http://www.LUGATI.com.br

Luiz Gustavo Schroeder Vieira

unread,
Sep 12, 2011, 12:29:54 PM9/12/11
to selenium-...@googlegroups.com
I got it, I used directly the driver, not the modalPanel to map the field.

Before:
WebElement modalPanel = driver.findElement(By.id("
corpo:formulario:painelGenericoContainer"));

WebElement dsArquivo = modalPanel.findElement(By.xpath("//*[@id='corpo:formulario:dsArquivo']"));

Now:
WebElement dsArquivo = driver.findElement(By.
xpath("//*[@id='corpo:formulario:dsArquivo']"));


Thanks mate!

2011/9/12 Luiz Gustavo Schroeder Vieira <gusta...@gmail.com>

Luiz Gustavo Schroeder Vieira

unread,
Sep 12, 2011, 1:13:05 PM9/12/11
to selenium-...@googlegroups.com
Hmm.. I got a new problem:

The URL I am using to get straight to the modal panel is losing reference to the page I've been before.

Is there any way to get to the modal panel without loosing its reference?
Reply all
Reply to author
Forward
0 new messages