テストスクリプトの実行中に次のエラーが発生しました。誰かが失敗の原因を特定するのを助けることができますか?テストスクリプトの実行中にNoSuchElementExceptionが発生しました
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"lid"}
Command duration or timeout: 20.45 seconds
ここに私のコードのスニペットがあります。要素が同じフレームに存在し、フレーム切り替えが不要であることに注意してください。要素の
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.support.ui.ExpectedConditions;
//import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class LoginPage
{
@Test
public void testLoginFail()
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.zoho.com/crm/");
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.linkText("LOGIN")).click();
//WebDriverWait wait = new WebDriverWait(driver,40);
//wait.until(ExpectedConditions.visibilityOfElementLocated((By.id("lid"))));
driver.findElement(By.id("lid")).sendKeys("[email protected]");
HTMLビューには、次のとおりです。
<input name="lid" id="lid" class="input usrbx" value="" onkeypress="clearmsg()" type="email">
''明示的待機 'の '' driver.findElement(By.id( "lid"))のsendKeys( "[email protected]"); 'ステートメントをラッピングしようとしましたか?また、ログインフォームHTMLを添付してください。人々はあなたを助けてくれるでしょう。私がやることは、ブラウザのコンソールを開いて、セレクタが '.val()'で入力を埋めているかどうかを調べることです。 (例: '$( '#lid').val(" [email protected] "))。コンソールJQueryで動作する場合は、セレクタで動作します。 :) – iamdanchiv
私はすでに明示的にこのステートメントをラップしようとしましたが、うまくいきませんでした。 – Dks
@Dksあなたは私のソリューションを試しましたか? –