问题
I see chromedriver is available on https://sites.google.com/a/chromium.org/chromedriver/ and also on https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver. However the versions are different in both cases.
In chromium website, it is mentioned as Current stable release: ChromeDriver 84.0.4147.30
In maven repository, it is mentioned as 4.0.0-alpha-6 as latest artifact.
Question: What is the difference between both and which one should be included as a project dependency for chromedriver.exe ? I am using a selenium java testng project.
回答1:
You are partially correct as they are different.
The ChromeDriver you see at ChromeDriver - WebDriver for Chrome is the executable binary which we use most commonly as in:
Java:
System.setProperty("webdriver.chrome.driver","C:\\WebDrivers\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.google.com/");
Python:
from selenium import webdriver driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe') driver.get("https://www.google.com/")
Where as the installation of Selenium libraries for Selenium-Java clients can be done using maven as well just by adding the selenium-java
dependency in your project pom.xml
which would support running your automation project with all Selenium supported browsers:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.X</version>
</dependency>
But if you want to run tests only in a specific browser, e.g. Chrome, you can add the Chrome specific dependency in the project pom.xml
file as follows:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.0.0-alpha-6</version>
</dependency>
The artifacts within Selenium Chrome Driver is the Selenium bindings specifically for the ChromeDriver and google-chrome combo.
回答2:
I think I figured it out after a bit research. Selenium ChromeDriver available in maven repository (4.0.0-alpha-6) is the class that implements WebDriver interface to support chrome browser specific methods. ChromeDriver (84.0.4147.30) mentioned in chromium.org is infact chromedriver.exe which is passed to Selenium ChromeDriver class to control chrome browser.
来源:https://stackoverflow.com/questions/63043619/chromedriver-versions-are-labelled-differently-in-chromium-website-and-maven-rep