【发布时间】:2017-08-03 03:13:48
【问题描述】:
driver.findElement(By.xpath(".//*[@id='js-fullscreen-hero']/div/form/div[1]/div/div/div[2]/button")).click();
new WebDriverWait(driver, 10 ).ignoring(StaleElementReferenceException.class).until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[@id='horus-shadowtext']")));
WebElement ele = driver.findElement(By.xpath(".//*[@id='horus-shadowtext' and @class='horus__shadowtext']"));
List<String> windowlist = new ArrayList<String>();
windowlist.add(driver.getWindowHandle());
int si= windowlist.size();
System.out.println(si);
Actions mouse2 = new Actions(driver);
mouse2.clickAndHold(ele).sendKeys(Keys.chord(Keys.CONTROL,"china")).build().perform();
ele.sendKeys(Keys.ENTER);
在此之后,即使是下面的步骤,它也无法执行任何步骤
driver.findElement(By.xpath(".//*[@id='js-fullscreen-hero']/div/form/div[1]/div[1]/div/div[2]/button")).click();
谁能帮我找出正确的解决方案。
【问题讨论】:
-
您能否总结一下您尝试自动化的确切手动步骤?您在哪一行看到错误?请更新问题区域中的错误堆栈跟踪以及相关的 HTML。谢谢
-
请用文字描述您要测试的用例。同时提供minimal reproducible example。理想情况下,这应该是 selenium 测试代码以及您尝试测试的代码的非常淡化的版本。
-
下面是错误日志
-
线程“主”org.openqa.selenium.NoSuchElementException 中的异常:无法定位元素:.//*[@id='js-fullscreen-hero']/div/form/div[ 3]/div[2]/button 有关此错误的文档,请访问:seleniumhq.org/exceptions/no_such_element.html Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'PEAMITRA', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121' 驱动信息: org.openqa.selenium.firefox.FirefoxDriver
-
当我没有使用控件时它能够定位元素。