[英]How to launch browser without setting local driver in selenium? (Without accessing local chromeDriver.exe)
public MainActionFlow() {
System.setProperty("webdriver.chrome.driver", "C://ChromeDriver_test//chromedriver.exe");
driverForTesting = new ChromeDriver();
this.driverForTesting.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
is there any way that we can launch browser without local drivers?有什么方法可以在没有本地驱动程序的情况下启动浏览器?
I think what you want is- downloading all the driver executables automatically?我认为您想要的是-自动下载所有驱动程序可执行文件? If so, yes its possible by using BoniGarcia's Webdrivermanager.如果是这样,是的,可以使用 BoniGarcia 的 Webdrivermanager。 WebDriverManager helps to download binanries/executables in an automated way. WebDriverManager 有助于以自动方式下载二进制文件/可执行文件。 It supports browsers such as Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, or Internet Explorer.它支持 Chrome、Firefox、Opera、PhantomJS、Microsoft Edge 或 Internet Explorer 等浏览器。
We just need to add its dependency through Maven or Gradle to download all the necessary drivers.我们只需通过 Maven 或 Gradle 添加其依赖项即可下载所有必要的驱动程序。 It will download ONLY if they are not present on the WebDriverManager cache (~/.m2/repository/webDriver by default).仅当 WebDriverManager 缓存中不存在它们时才会下载(默认为 ~/.m2/repository/webDriver)。
Add following dependency in your POM在您的 POM 中添加以下依赖项
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.4.3</version>
<scope>test</scope>
</dependency>
Once this is done you can instantiate your driver session by just below line -完成此操作后,您可以通过以下行实例化您的驱动程序 session -
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
visit this page for more details- https://github.com/bonigarcia/webdrivermanager访问此页面了解更多详情 - https://github.com/bonigarcia/webdrivermanager
You should have some webdriver running at remote computer.您应该在远程计算机上运行一些 webdriver。 Then You do somehting like this:然后你做这样的事情:
ChromeOptions chromeOptions = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://www.example.com"), chromeOptions);
driver.get("http://www.google.com");
driver.quit();
Where http://www.example.com
is the URL your remote web driver is accessible with.其中http://www.example.com
是 URL 您的远程 Z2567A5EC9705EB7AC2DZ98403 驱动程序可访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.