Hi,

I am stuck while automating the below scenario using selenium webdriver.
I have a pop up window and a modal pop up window inside this pop up window.
In this modal pop up window, am changing some value and clicking on a
button, which will close this modal pop up window and a javascript
confirmation window gets opened.
This confirmation window is having buttons: 'Yes', 'No' and 'Cancel'.

I am using below code to switch the control to modal pop up window and
operate in this window.
But after this i am not able to click on the confirmation message window.
I have already tried with Alert alert = driver.switchto().alert(), but its
not working. Its saying that no alert message found.
Please tell me how to proceed from here.

String winHandleBefore = driver.getWindowHandle();

driver.findElement(By.id("btnChangeWorkType")).click();

Thread.sleep(2000);
java.util.Set<String> availableWindows = driver.getWindowHandles();
while(true){
availableWindows = driver.getWindowHandles();
if(availableWindows.size()==2)
break;

System.out.println(availableWindows.size());
String npopup = null;
for(String win:availableWindows){

if(!win.equals(winHandleBefore)){
npopup=win;
}
}

driver.switchTo().window(npopup)
new
Select(driver.findElement(By.id("ddlWorkType"))).selectByVisibleText("PROGRESS
NOTE");
driver.findElement(By.id("btnOk")).submit(); // This will
close the modal pop up window and javascript confirmation window gets
opened.

}


Regards,
Rajesh

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Neeraj Sharma at Sep 25, 2012 at 4:18 pm
    Try this:

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

    Neeraj Sharma
    On Tuesday, 25 September 2012 21:46:22 UTC+5:30, Rajesh Ranjan wrote:

    Hi,

    I am stuck while automating the below scenario using selenium webdriver.
    I have a pop up window and a modal pop up window inside this pop up window.
    In this modal pop up window, am changing some value and clicking on a
    button, which will close this modal pop up window and a javascript
    confirmation window gets opened.
    This confirmation window is having buttons: 'Yes', 'No' and 'Cancel'.

    I am using below code to switch the control to modal pop up window and
    operate in this window.
    But after this i am not able to click on the confirmation message window.
    I have already tried with Alert alert = driver.switchto().alert(), but its
    not working. Its saying that no alert message found.
    Please tell me how to proceed from here.

    String winHandleBefore = driver.getWindowHandle();

    driver.findElement(By.id("btnChangeWorkType")).click();

    Thread.sleep(2000);
    java.util.Set<String> availableWindows =
    driver.getWindowHandles();
    while(true){
    availableWindows = driver.getWindowHandles();
    if(availableWindows.size()==2)
    break;

    System.out.println(availableWindows.size());
    String npopup = null;
    for(String win:availableWindows){

    if(!win.equals(winHandleBefore)){
    npopup=win;
    }
    }

    driver.switchTo().window(npopup)
    new
    Select(driver.findElement(By.id("ddlWorkType"))).selectByVisibleText("PROGRESS
    NOTE");
    driver.findElement(By.id("btnOk")).submit(); // This will
    close the modal pop up window and javascript confirmation window gets
    opened.

    }


    Regards,
    Rajesh
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/PcK3fSxXT3gJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rajesh at Sep 25, 2012 at 4:38 pm
    Hi have already tried with same and its saying no active alert found as
    mentioned in the query posted.
    Please find below the exception i am getting for even doing a SOP inside
    the while loop and outside the while loop:


    1. In this case I am getting a window saying “javaw.exe has encountered
    a problem and needs to close.



    String winHandleBefore = driver.getWindowHandle();



    driver.findElement(By.*id*("btnChangeWorkType")).click();

    Thread.*sleep*(2000);

    java.util.Set<String> availableWindows = driver.getWindowHandles
    ();

    *while*(*true*){

    availableWindows = driver.getWindowHandles();

    *if*(availableWindows.size()==2)

    *break*;



    System.*out*.println(availableWindows.size());

    String npopup = *null*;

    *for*(String win:availableWindows){



    *if*(!win.equals(winHandleBefore)){

    npopup=win;

    }

    }



    driver.switchTo().window(npopup);



    *new* Select(driver.findElement(By.*id*("ddlWorkType"))).
    selectByVisibleText("PROGRESS NOTE");



    driver.findElement(By.*id*("btnOk")).submit();

    Thread.*sleep*(4000);

    System.*out*.println(driver.getTitle());

    }





    1. *org.openqa.selenium.WebDriverException*: Unable to get browser



    String winHandleBefore = driver.getWindowHandle();

    driver.findElement(By.*id*("btnChangeWorkType")).click();

    Thread.*sleep*(2000);

    java.util.Set<String> availableWindows = driver.getWindowHandles
    ();

    *while*(*true*){

    availableWindows = driver.getWindowHandles();

    *if*(availableWindows.size()==2)

    *break*;



    System.*out*.println(availableWindows.size());

    String npopup = *null*;

    *for*(String win:availableWindows){



    *if*(!win.equals(winHandleBefore)){

    npopup=win;

    }

    }



    driver.switchTo().window(npopup);



    *new* Select(driver.findElement(By.*id*("ddlWorkType"))).
    selectByVisibleText("PROGRESS NOTE");



    driver.findElement(By.*id*("btnOk")).submit();

    Thread.*sleep*(4000);



    }
    System.*out*.println(driver.getTitle());



    Regards,
    Rajesh
    On Tue, Sep 25, 2012 at 9:48 PM, Neeraj Sharma wrote:

    Try this:

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

    Neeraj Sharma
    On Tuesday, 25 September 2012 21:46:22 UTC+5:30, Rajesh Ranjan wrote:

    Hi,

    I am stuck while automating the below scenario using selenium webdriver.
    I have a pop up window and a modal pop up window inside this pop up
    window.
    In this modal pop up window, am changing some value and clicking on a
    button, which will close this modal pop up window and a javascript
    confirmation window gets opened.
    This confirmation window is having buttons: 'Yes', 'No' and 'Cancel'.

    I am using below code to switch the control to modal pop up window and
    operate in this window.
    But after this i am not able to click on the confirmation message window.
    I have already tried with Alert alert = driver.switchto().alert(), but
    its not working. Its saying that no alert message found.
    Please tell me how to proceed from here.

    String winHandleBefore = driver.getWindowHandle();

    driver.findElement(By.id("**btnChangeWorkType")).click();

    Thread.sleep(2000);
    java.util.Set<String> availableWindows =
    driver.getWindowHandles();
    while(true){
    availableWindows = driver.getWindowHandles();
    if(availableWindows.size()==2)
    break;

    System.out.println(**availableWindows.size());
    String npopup = null;
    for(String win:availableWindows){

    if(!win.equals(**winHandleBefore)){
    npopup=win;
    }
    }

    driver.switchTo().window(**npopup)
    new Select(driver.findElement(By.**id("ddlWorkType"))).**selectByVisibleText("PROGRESS
    NOTE");
    driver.findElement(By.id("**btnOk")).submit(); // This
    will close the modal pop up window and javascript confirmation window gets
    opened.

    }


    Regards,
    Rajesh

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

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedSep 25, '12 at 4:16p
activeSep 25, '12 at 4:38p
posts3
users2
websiteseleniumhq.org

2 users in discussion

Rajesh: 2 posts Neeraj Sharma: 1 post

People

Translate

site design / logo © 2022 Grokbase