Tutorial Installing Selenium on Python

Posted in Uncategorized

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Install Selenium on Python

We first install Selenium Python package by this …

pip install selenium

Run Chrome Test

We have to download “ChromeDriver Web Driver for Chrome” and copy it to same location as your Python script. This is only done for convenience for the purpose of this tutorial. In reality, you should put it in some common location, and reference it via path in the “driverLocation” variable of your script.

Write Python script called “test_chrome.py” as follows…

When you run this script with …

python test_chrome.py

It should launch your browser to the google.com page.

Run Firefox Browser Test

For Firefox, download the “gecko driver” and put next to script. Create another script call test_firefox.py with the following…

Run Safari Browser Test

Instead of downloading the browser driver, download the “selenium standalone server” jar file and copy it next to your script …

To allow Safari to be remotely controlled, “Show Developer menu in menu bar”…

And checkmark “Allow Remote Automation” …

Adding Driver Location in the Path

While in the above, we had hard-coded the paths to the browser drivers; it is not necessary if we put all the drivers in one central location and add that location to the system PATH in the .bash_profile …

Then you can clean your scripts by removing (or commenting out) the lines shown…

Selenium will look for the drivers in the PATH specified.


Related Posts

Tags

Share This