Selenium

Python selenium bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. Selenium Python bindings offers developers and QA engineers a convenient API to access Selenium WebDrivers like Firefox, Chrome etc.

To use Python Selenium bindings, you need to install Python language and Python Selenium bindings. Follow the steps to install python selenium bindings:

  • Step 1: Python Installation

    1. Download latest version of python. Click here to install python
  • Step 2: Selenium Installation

    1. Open command prompt(terminal for Mac Users) and type command:


      pip install selenium

  • Step 3: Selenium Drivers Installation

    1. Selenium requires a driver to interface with the chosen browser. For example, Chrome needs chromedriver so we have to install it. Click here to download
    2. For windows, extract chromedriver_win32.zip and it will give you a file called chromedriver.exe.
      Place chromedriver.exe file in Scripts folder(open python folder then you will see Scripts folder) e.g C:\python\Scripts
    3. Now add it in your PATH. Follow the steps to add it into your PATH.
      Open your PC properties(right click on my computer)
      Click “Advanced System Setting”
      selenium

      Dialog box will open. Click on “Environment Variables”
      selenium

      Now again dialog box open, click on Path in System Variables and then click on Edit
      selenium

      Now simply add your chromedriver path e.g C:\python\Scripts
      selenium

      Make sure that you have Chrome (or Firefox) browser installed.
  • Step:4 Verify Installation

from selenium import webdriver
browser=webdriver.Chrome()
browser.get('http://www.google.com')
Important: If Python can’t find Chrome/Firefox, you can just tell Python where it is when you’re loading it up.
from selenium import webdriver
options = webdriver.ChromeOptions()
#add chrome browser exe path.
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
#add chromedriver.exe path
driver=webdriver.Chrome(options=options,executable_path="C:/Python/Scripts/chromedriver.exe")
driver.get("http://google.com")

Popular IDE’s for python Development:


5 Comments

bocahickory.com · May 24, 2019 at 10:27 am

Heya i’m for the first time here. I came across this board and I find It truly
useful & it helped me out much. I hope to give something back and help others
like you aided me.

Crypto Master Course · May 31, 2019 at 2:27 am

Awesome website you have here but I was curious about if you knew of any discussion boards that cover the same topics discussed in this article? I’d really love to be a part of community where I can get advice from other experienced individuals that share the same interest.

If you have any recommendations, please let me know.

Thank you!

NL Brand Reviews · August 19, 2019 at 9:18 pm

Great article, just what I needed.

Practical Web Scraping using Python - SmartSpidering · April 29, 2019 at 1:51 pm

[…] Selenium Webdriver […]

BYPASS Restrictions using PROXIES - SmartSpidering · June 22, 2019 at 4:23 pm

[…] Selenium Webdriver […]

Leave a Reply

Your email address will not be published. Required fields are marked *