I've been trying to study Selenium in ways we can incorporate it in our testing. I've read and watched some tutorial and it basically needs to use chromedriver.exe set as webdriver.chrome.driver property. However, our company policies restrict us from using/executing exe files. As a result, when I try my code for Selenium chrome, I get an error that the exe trying to execute is unauthorize.
So my question is that, is there any way I can use Selenium for chrome without having to use chromedriver.exe? If you know a link for a documentation, turorial or even a youtube guide, please let me know. Thanks!
It may not be a good practice but you can do it using AutoIT. Launch the chrome browser and AutoIT code using Runtime class in your project.
Why do you need ChromeDriver? The main purpose of the ChromeDriver is to launch Google Chrome. Without that, it is not possible to execute Selenium test scripts in Google Chrome as well as automate any web application. This is the main reason why you need ChromeDriver to run test cases on Google Chrome browser.
Users provided relevant link to confirm that, "YES" a full Chrome installation is needed in addition to the actual chromedriver.
The shortest answer is: You need both, if you want to test using Chrome. WebDriver is the Selenium library of code containing the FindBys and Clicks and SendKeys code. ChromeDriver is a library of code that controls the Chrome Browser. In order to create your test scripts, you need WebDriver.
If it is maven based project and you are using latest version of selenium-chrome-driver and webdrivermanager, you can try to use below dependencies in pom.xml
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.7.1</version>
</dependency>
Use WebDriverManager,
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
If your project is Maven based, you can add below dependency. This has ChromeDriverManager class which takes care of chromedriver binary file and also it maintains latest version of binary file, reducing the manual work of maintaining the driver exe file manually.
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.7.2</version>
<scope>test</scope>
</dependency>
ChromeDriverManager.getInstance().setup();
driver = new ChromeDriver();
driver.get("http://www.google.co.in");
I have recently tried this and still have to evaluate pros and cons. Please mention your points on pros/cons if get more information. Thanks.
I believe it is not possible to use chrome browser in Selenium without using chromedriver.exe. The same applies to Internet Explorer as well.
However, if you are really prohibted from using .exe files, then executing your test scripts in Firefox will be helpful. All you need to do is to add the below code:
driver = new FirefoxDriver();
No need to refer any .exe files when it comes to Firefox. Hope this helps!
UPDATE: After Selenium 3 even Firefox needs geckodriver.
Yes, you can use without downloading chromedriver.exe file
pip install webdriver-manager
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
go to the official website for more info.
https://pypi.org/project/webdriver-manager/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With