eclipse 如何升级/更新现有 Selenium Java 项目的 Selenium 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13294218/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to upgrade/update Selenium version of an existing Selenium Java project?
提问by OrwellHindenberg
I have a Selenium WebDriver project with eclipse IDE on Ubuntu 11 OS. I want to upgrade the java client driver from 2.24 to 2.25. How can I do this?
我在 Ubuntu 11 操作系统上有一个带有 Eclipse IDE 的 Selenium WebDriver 项目。我想将 java 客户端驱动程序从 2.24 升级到 2.25。我怎样才能做到这一点?
回答by OrwellHindenberg
I downloaded the java client driver from the selenium website (2.25.0) http://seleniumhq.org/download/. Unpack the zip file to the dir of your choice.
我从 selenium 网站 (2.25.0) http://seleniumhq.org/download/下载了 java 客户端驱动程序。将 zip 文件解压到您选择的目录。
Start-up eclipse and select the project you are working on. Add the latest selenium jar to the referenced lib by going to Properties->Java Build Path->Add External JARs (select the selenium jar). To do things in a clean way I removed the references to the other libs that had been there along with the older selenium (2.24) and replaced them with the new versions. You can find the new jars under selenium-2.25.0/libs folder. Add them the same way you added selenium-2.25.0.jar.
启动 eclipse 并选择您正在处理的项目。通过转到 Properties->Java Build Path->Add External JARs(选择 selenium jar),将最新的 selenium jar 添加到引用的库中。为了以干净的方式做事,我删除了对与旧版 selenium (2.24) 一起存在的其他库的引用,并将它们替换为新版本。您可以在 selenium-2.25.0/libs 文件夹下找到新的 jar。以与添加 selenium-2.25.0.jar 相同的方式添加它们。
Note: This will break your project if you don't add the jar files correctly so you may want to create a backup of your project.
注意:如果您没有正确添加 jar 文件,这将破坏您的项目,因此您可能需要创建项目的备份。
回答by Johnny
For everyone that still coming here...
对于仍然来到这里的每个人......
You can try and integrate to your project the WebDriverManagerlibrary.
您可以尝试将WebDriverManager库集成到您的项目中。
It would easily allow you to automate the install process of different WebDriver implementations (binaries).
它可以轻松地让您自动执行不同 WebDriver 实现(二进制文件)的安装过程。
For example, for ChromeDriver:
例如,对于 ChromeDriver:
ChromeDriverManager.getInstance().setup(); //downloading and installing ChromeDriver
WebDriver driver = new ChromeDriver(); //initializing ChromeDriver
If you use Maven, add it's dependency to your pom.xml file:
如果您使用 Maven,请将其依赖项添加到您的 pom.xml 文件中:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.3.1</version>
</dependency>