Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.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
Java WebDriver异常org.openqa.selenium.NoSuchElementException_Java_Selenium Webdriver - Fatal编程技术网

Java WebDriver异常org.openqa.selenium.NoSuchElementException

Java WebDriver异常org.openqa.selenium.NoSuchElementException,java,selenium-webdriver,Java,Selenium Webdriver,当我尝试使用WebDriver打开与本地服务器的链接时,会出现此错误 org.openqa.selenium.NoSuchElementException:无法定位元素: phpmyamin开幕 但是,当我尝试使用XPath单击链接时,错误就开始了。 最有趣的是,网站工作正常,只有在本地服务器上运行时才会发生错误。 就在Selenium IDE的另一端,它工作得很好 WebDriver driver = new FirefoxDriver(); driver.get("http://127.0.

当我尝试使用
WebDriver
打开与本地服务器的链接时,会出现此错误

org.openqa.selenium.NoSuchElementException:无法定位元素: phpmyamin开幕

但是,当我尝试使用XPath单击链接时,错误就开始了。 最有趣的是,网站工作正常,只有在本地服务器上运行时才会发生错误。 就在Selenium IDE的另一端,它工作得很好

WebDriver driver = new FirefoxDriver();
driver.get("http://127.0.0.1/Tools/phpmyadmin/");
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);

WebElement link = driver.findElement(By.xpath("//ul[@id='databaseList']/li/a"));
link.click();

尝试在调试模式下运行。可能2秒不够时间不确定是否可以共享html源代码,如果可能的话,就异常而言,这意味着ur xpath不正确。