Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 虽然Xpath可用,但会引发元素未找到错误_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Selenium 虽然Xpath可用,但会引发元素未找到错误

Selenium 虽然Xpath可用,但会引发元素未找到错误,selenium,selenium-webdriver,selenium-chromedriver,Selenium,Selenium Webdriver,Selenium Chromedriver,帐户搜索 #btnprog { 边框样式:无; 边框颜色:继承; 边框宽度:中等; 宽度:73px; 不透明度:1; 背景:无; } 函数CheckAccountName(txtbox,minlength){ //警报(txtbox); txt=document.getElementById(txtbox); 如果(txt.value.length


帐户搜索
#btnprog
{
边框样式:无;
边框颜色:继承;
边框宽度:中等;
宽度:73px;
不透明度:1;
背景:无;
}
函数CheckAccountName(txtbox,minlength){
//警报(txtbox);
txt=document.getElementById(txtbox);
如果(txt.value.length很可能您只需要等待元素出现。使用而不是
findElement

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement txtAccountName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='txtAccountName']")));
txtAccountName.sendKeys("CRSsolutions_test_" + today + "_tanksafe");

此模式允许最多等待10秒,但如果条件满足,返回速度会更快。条件
elementtobelickable
确保字段可单击,这是输入值的先决条件。

查看您是否没有使用wait进行定位,然后需要使用绝对xpath来定位该元素。或者您可以使用css选择器也是

对于有角度的网页,普通的xpath无法定位元素。如果是有角度的,我建议使用量角器工具来自动化selenium


否则,如果相对xpath未找到您的元素,则绝对xpath将起作用。

已尝试但未起作用。预期条件失败:等待元素可单击:By.xpath://input[@name='txtAccountName'](以500毫秒的间隔尝试10秒)原因:org.openqa.selenium.NoSuchElementException:无法使用by.xpath://input[@name='txtAccountName']查找元素好吧,由于无法访问该站点,并且您没有提供任何html,因此我无法提供任何其他帮助。请您提供帮助。等待您的回复。