有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Firefox webdriver在Phanthon Js不工作的地方工作

下面的脚本在firefox中可用,但在Phanthon Js中不可用

driver.manage().window().maximize();
// Enter UserName
driver.findElement(By.xpath(".//*[@type='text']")).sendKeys("admin");
// Enter Password
driver.findElement(By.xpath(".//*[@type='password']")).sendKeys(
        "admin");
// Wait For Page To Load
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
// Click on 'Sign In' button
driver.findElement(By.xpath(".//button[@type='button']")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement webElement =    driver.findElement(By.xpath("//button[contains(text(),'OK')]"));
webElement.click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//span[contains(text(),'Process')]"))

错误

Caused by: org.openqa.selenium.NoSuchElementException: 
{"errorMessage":"Unable to find element with xpath 
'.//span[contains(text(),'Process')]'","request":{"headers":{"Accept-
Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-
Length":"60","Content-Type":"application/json; charset=utf-
8","Host":"localhost:32339","User-Agent":"Apache-HttpClient/4.4.1 
(Java/1.8.0_60)"},"httpVersion":"1.1","method":"POST","post":".......

有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html

  1. 为什么Phanthon JS在使用firefox web驱动程序运行良好时拒绝工作
  2. 如何在没有浏览器的情况下运行程序headless,即与firefox webdriver代码兼容
  3. 快速为headless准备脚本的替代方法

共 (0) 个答案