我试图找到带有id
元素的用户名字段。但是,"无法找到元素"。即使我尝试了显式的wait/Thread/Xpath/CSSSelector,但仍然无法找到该元素。
法典:
naukriProfileCreation.findElement(By.id("identifierId")).sendKeys("vinodchris");
// WebDriverWait username = new WebDriverWait(naukriProfileCreation, 15);
// WebElement id = username.until(ExpectedConditions.presenceOfElementLocated(
// By.xpath("//input[@id='identifierId']")));
// id.sendKeys("vinodchris");
目录:
<div class="Xb9hP">
<input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username"
spellcheck="false" tabindex="0" aria-label="Email or phone"
name="identifier" autocapitalize="none" id="identifierId"
dir="ltr" data-initial-dir="ltr" data-initial-value="">
<div jsname="YRMmle" class="AxOyFc snByac" aria-hidden="true">Email or phone</div>
</div>
错误:
线程"main"
org.openqa.selenium.NoSuchElementException
中的异常:找不到元素:#identifierId
driver.findElement(By.id('indentifierId')).sendKeys("vinodchris");
在发送密钥之前,请尝试等待控件出现。在秒钟,您可以发送密钥:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("identifierId")));
driver.findElement(By.id("identifierId")).sendKeys("vinodchris");