Python Selenium
About Lesson

In this Python Selenium lesson we want to learn How to Install Selenium Web Driver in Python, we are going to learn how to install Python Selenium, how you can add Chrome and Firefox drivers in Python Selenium and at the end we want to create a simple example in Selenium Web Driver using Python Programming Language.



What is Selenium ?

Selenium is a set of tools for browser automation, and it is mostly used for testing applications. but the usage of selenium is not limited to testing of applications, but it can also be used for screen scrapping and repetitive tasks automation in a browser.  so selenium supports automation for different browsers like firefox, internet explorer, google chrome, safari  and opera.



There are different tools of selenium that you can use

  • Selenium IDE: This is a Firefox add-in used to record and play back the
    Selenium scripts with Firefox. It provides a graphical user interface to
    record user actions using Firefox.
  • Selenium Web Driver: This is programming interface, and it is used with programming languages like Java,Python,C#, Ruby, PHP and JavaScript. and the web drivers supports different browsers like, Google Chrom, Mozila Firefox, Internet Explorer, Opera and Safari.
  • Selenium Stand Alone Server: This is also known as Selenium Grid and  allows remote and distrbuted execution of Selenium scripts created with WebDriver.




What is Python Selenium ?

Python Selenium bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium API you can access all functionalities of Selenium WebDriver in an intuitive way. Selenium bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome, Remote etc. The current supported Python versions are 2.7, 3.5 and above.





For the installation you can just use pip.





Selenium requires a driver to interface with the chosen browser, and there are different driver for each browsers that you need to download, it is just an exe file, after downloading just copy and paste the driver where you have installed your python. these are the most popular drivers download link for different browsers.





After installation now you need to import selenium web driver.



If you want to open a browser than you can use this code, in here i have used Chrome and FireFox browsers.



If you want to open a website than you can add this code.




This is the code.




Run the code and this is the result.

How to Install Selenium Web Driver in Python
How to Install Selenium Web Driver in Python




These are some web properties for the driver, like printing the title of the web page, current url and page source.




And these are some web browser commands, for example you can set the screen of the browser and also x and y position of the browser.