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

时间:2015-10-11 17:39:37

标签: java selenium-webdriver phantomjs

以下脚本在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网络驱动程序正常工作时拒绝工作?
  2. 如何运行无头程序,即没有与firefox webdriver代码兼容的浏览器?
  3. 为无头快速准备脚本的替代方法?

0 个答案:

没有答案