Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to switch to pop-up window and find any elements in pop-up in Webdriver using Java
    primarykey
    data
    text
    <p>I have an application in which i tried clicking on a button and in return it will pop-up a window for filling a new user form. This is not really like a pop-up window, because it has some input fields as well as "save " and "cancel" button. It looks similar to pop-up window in facebook.</p> <p>Here the code i tried with</p> <pre><code>Set beforePopup = driver.getWindowHandles(); driver.findElement(By.xpath("/html/body/div/div/div/div[3]/div/div[2]/div[2]/table/tbody/tr/td[3]/table/tbody/tr/td[2]/em/button")).click(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); Set afterPopup = driver.getWindowHandles(); afterPopup.removeAll(beforePopup); if(afterPopup.size() == 1) { driver.switchTo().window((String)afterPopup.toArray()[0]); } //driver.switchTo().window("Add New User"); //selenium.type("userDetailsBean.firstName","alan1"); //WebElement btnStartQueryInside = driver.findElement(By.xpath("//html/body/div[14]/div/div/div/div/span")); //btnStartQueryInside.getText(); System.out.println(driver.getTitle()); WebElement firstName = driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/form/div/div/input")); firstName.sendKeys("alan1"); //driver.switchTo().alert(); //driver.findElement(By.xpath("//html/body/div[14]/div/div/div/div")).getText(); //WebElement firstName=driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/form/div/div/input")); //firstName.sendKeys("alan1"); /*WebElement lastName=driver.findElement(By.id("userDetailsBean.lastName")); lastName.sendKeys("harper"); WebElement emailadd=driver.findElement(By.id("userDetailsBean.userEmail")); emailadd.sendKeys("alan1@derik.com"); WebElement username=driver.findElement(By.id("userDetailsBean.userName")); username.sendKeys("xalan1"); WebElement password=driver.findElement(By.id("adminPassword")); password.sendKeys("Derik123"); WebElement repassword=driver.findElement(By.id("adminPassword2")); repassword.sendKeys("Derik123"); driver.findElement(By.xpath("//html/body/div[2]/div/div/div/div/div[2]/div/div/table/tbody/tr/td/table/tbody/tr/td[2]/em/button")).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);*/ </code></pre> <p>Please note that in code I commented some input field filling, because I thought first I will make it working just for 1st field. Please help me how to proceed.</p> <p>the problem is after clicking the pop-up button, I'm not sure if the control switches to pop-up window or not. the gettitle after pop-up gives the main window title. and it is not able to find the first input field using the xpath or id.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload