繁体   English   中英

无法使用id / name / xpath / CSSSelector定位元素

[英]Unable to locate the element using id/name/xpath/CSSSelector

我试图找到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");

HTML:

 <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> 

错误:

线程“主要” 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");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM