Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Selenium (webdriver) for Chrome without using chromedriver.exe?

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!

like image 465
learning_dev_me Avatar asked Jul 20 '15 07:07

learning_dev_me


People also ask

Can we use Selenium without ChromeDriver?

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 I need ChromeDriver exe?

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.

Do I need to install Chrome to use ChromeDriver?

Users provided relevant link to confirm that, "YES" a full Chrome installation is needed in addition to the actual chromedriver.

What is the difference between Selenium WebDriver and 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.


4 Answers

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");  
like image 171
Nagaraja JB Avatar answered Oct 04 '22 22:10

Nagaraja JB


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.

like image 32
Aftaab Siddiki Avatar answered Oct 05 '22 00:10

Aftaab Siddiki


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.

like image 33
justcurious Avatar answered Oct 04 '22 22:10

justcurious


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/

like image 38
Judah shaik Avatar answered Oct 04 '22 22:10

Judah shaik