1

I'm getting org.openqa.selenium.WebDriverException error.

My code is:

@Test(priority = 3)
public void transactionCancel() throws Exception {
    WebDriverWait wait = new WebDriverWait(driver, 60);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(MyLocators.Transaction_btnBuy)));
    WebElement button = driver.findElement(By.cssSelector(MyLocators.Transaction_btnBuy));
    button.click();

    //popup window handling
    Set<String> allHandle = driver.getWindowHandles(); // Fetch all handles
    Iterator<String> iterator = allHandle.iterator();
    Object popupR = new Object();
    while (iterator.hasNext()) {
        popupR = iterator.next();
    }
    driver.switchTo().window((String) popupR); // switch to popup
    String parentWindowHandler = new String();
    driver.switchTo().window(parentWindowHandler);

    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(MyLocators.Transaction_popupCancel)));
    button = driver.findElement(By.xpath(MyLocators.Transaction_popupCancel));
    button.click();

}
2
  • 6
    Which line is throwing the exception? Also, what is the full stack dump?
    – Kate Paulk
    Aug 24 '17 at 11:28
  • Where you got an issue Aug 31 '17 at 10:08
6

The string parentWindowHandler is not assigned a value.
So the line driver.switchTo().window(parentWindowHandler); will not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.