Unable to locate an element using xpath error in selenium-java

前端 未结 4 940
忘掉有多难
忘掉有多难 2021-01-17 06:23

This is the code I am trying to execute

public WebDriver createPart() {

    try {
        driver.findElement(By.id(\"username\")).sendKeys(\"502409373\");
          


        
4条回答
  •  佛祖请我去吃肉
    2021-01-17 06:53

    your parentWindowHandler should not be correct, you fetch it at wrong time point.

    Try move below code line to the first line in the try block

    try {
       String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
    

提交回复
热议问题