2017-12-16 10 views
0

にユーザー名とパスワードを入力することができません:way2automation登録ページでユーザー名とパスワードを入力しようとしているときに、私は次のエラーメッセージを取得していますway2automation.com

org.openqa.selenium.remote.ProtocolHandshakeのCreateSession
INFO :検出方言:OSS
org.openqa.selenium.ElementNotVisibleException:後

見えない要素が私のコードです:

public void SignIn() { 
    try { 
     driver.findElement(By.linkText("Signin")).click(); 
     Thread.sleep(3000); 

     driver.findElement(By.xpath("//*[@id=\"load_form\"]/fieldset[6]/input")).sendKeys("ankit_21"); 
     driver.findElement(By.xpath("//*[@id=\"load_form\"]/fieldset[7]/input")).sendKeys("automation"); 

    } catch (InterruptedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
} 
も同様に動作しませんでした

findElement(By.name("password")).sendKeys("automation"); 

によって要素を検索してみました。 、あなたが最初のポップアップウィンドウに切り替える必要があり

driver.findElement(By.xpath("//input[@id='user_email']")).sendKeys("ankit_21"); 
driver.findElement(By.xpath("//input[@id='user_password']")).sendKeys("automation"); 
+0

新しいウィンドウに切り替える必要があります。 – lauda

+1

ここにコードのhtml部分を貼り付けてください –

答えて

0

を助けてくださいそこに戻り、再度作業する必要があるときにメインウィンドウに戻ります。

String parentWindow = driver.getWindowHandle(); //main window 
    WebElement loginButton = driver.findElement(By.className("btn-primary")); 
    loginButton.click(); 

    Set<String> handles = driver.getWindowHandles(); //gets all the windows (this code assumes there are only two in total 
    for (String windowHandle : handles) { 
     if (!windowHandle.equals(parentWindow)) { 
      driver.switchTo().window(windowHandle); //switches to the popup window 
     } 
    } 

    WebElement usernameField = driver.findElement(By.id("user_email")); 
    usernameField.click(); 
    usernameField.sendKeys("ankit_21"); 
    WebElement passwordField = driver.findElement(By.id("user_password")); 
    passwordField.click(); 
    passwordField.sendKeys("automation"); 

    driver.close(); //close child window 
    driver.switchTo().window(parentWindow); //control the parent window 
0

のアクションを実行します。

次のコードブロックを使用することができますway2automation registration pageusernamepasswordを入力するには

関連する問題