【问题标题】:Maven Project - Do we require set property while writing Automation script?Maven 项目 - 编写自动化脚本时是否需要设置属性?
【发布时间】:2021-08-08 10:02:32
【问题描述】:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Locators {

public static void main(String ars[]) throws InterruptedException {
    
    WebDriver driver = new ChromeDriver();
    
    driver.manage().window().maximize();
    driver.get("https://www.google.com");
    Thread.sleep(5000);
    driver.close();
}

}

收到此错误...

>     Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable The path to the driver executable

必须 > 由 webdriver.chrome.driver 系统属性设置;更多 > 信息,请参阅 >https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver。最新的 > 版本可以从 > http://chromedriver.storage.googleapis.com/index.html > 在 org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:280) > 在 org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142) > 在 org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:37) > 在 org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:222) > 在 org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:419) > 在 org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:119) > 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:41) > 在 Selenium.SeleniumPrograms.Locators.main(Locators.java:10)

【问题讨论】:

  • 我使用的是 Maven,所以我还需要配置 setproperty 吗?

标签: selenium maven


【解决方案1】:

是的,你需要。 selenium 应该可以使用可执行文件来执行 UI 操作。

// Configuring the system properties of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\Selenium-java\\chromedriver_win32chromedriver.exe"); 

这对于 Firefox 可能不是必需的。看到这个here

【讨论】:

  • 那么 chrome 依赖项呢?他们不是在这种情况下工作吗?
  • 为此使用 chrome 选项。顺便说一句,您的要求是什么?
猜你喜欢
  • 2018-12-06
  • 2014-12-02
  • 2017-08-08
  • 1970-01-01
  • 1970-01-01
  • 2015-06-22
  • 1970-01-01
  • 2020-06-24
  • 1970-01-01
相关资源
最近更新 更多