Java Selenium WebDriver-即使存在元素,也会出现获取NoTouchElementException错误
我试图单击应用程序中的下拉框,Xpath是:Java Selenium WebDriver-即使存在元素,也会出现获取NoTouchElementException错误,java,selenium,webdriver,Java,Selenium,Webdriver,我试图单击应用程序中的下拉框,Xpath是:/*[@id='sel2O5\u chzn']/a 但是当我试着点击它的时候,我并没有感到意外 应用程序中存在偶数元素。在IE上试用,Chrome和Firefox仍然面临同样的问题 driver.findElement(By.xpath("//*[@id='sel2T1_chzn']/a")).click(); 也尝试过下面的方法,但没有运气。得到同样的非接触性异常 请帮助我解决此问题使用显式等待,它允许您等待通过WebDriver定位元素,并且是您
/*[@id='sel2O5\u chzn']/a
但是当我试着点击它的时候,我并没有感到意外
应用程序中存在偶数元素。在IE上试用,Chrome和Firefox仍然面临同样的问题
driver.findElement(By.xpath("//*[@id='sel2T1_chzn']/a")).click();
也尝试过下面的方法,但没有运气。得到同样的非接触性异常
请帮助我解决此问题使用
显式
等待,它允许您等待通过WebDriver
定位元素,并且是您可以使用的预期条件的列表
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='sel2T1_chzn']")));
myDynamicElement.click();
你能为下拉列表分享相关的HTML代码吗?有两种可能。1-显示元素需要时间。2-元素位于iframe或frame中。你能探索一下这两种可能性吗。如果你能提供HTML代码片段,它将帮助我们。
WebElement myDynamicElement = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='sel2T1_chzn']")));
myDynamicElement.click();