Selenium package is mostly used for automation like in web browsers. Or in detail, it is an open-source web-based automation tool. Python language is used with selenium for testing and the python API’s empower you to connect with the browser through selenium. Selenium can send the
standard python commands to different browsers, despite variation in their browser’s design.
In this article we first see installation of selenium then Sample selenium code
Table of Contents
How to install selenium for windows
Python command is Same for Installing Selenium Library for different OS.
python -m pip install selenium
If we want to update the existing version of selenium, use then he below command
pip install –U selenium
Once the installation of the selenium library is complete.
We can verify the selenium version by using the below command.
pip show selenium
Also read : Class and Object in python
Sample code for selenium with python
from selenium import webdriver
username=”sachedusupport”
password=”sachedus”
url=https://www.facebook.com/
diver=webdriver.Chrome('C:\\Users\\Sachperfect\\Documents\\chromedriver_win32\\chromedriver')
driver.get(url)
driver.find_element_by_id(‘email).send_keys(username)
driver.find_element_by_id(‘pass).send_keys(password)
button = driver.find_element_by_id(‘u_0_b’)
button.click()
Output for selenium with python
This code explain about automation of web browser. I took an example of Facebook Url ,this code is help to open Facebook page and enter username and password and click submit button automatically. Then the account holder page will be opened.
This is how selenium package with python helps for automation.
Also see : Different modules in python
Summary :
In this article we saw selenium python example code so about this section you have any query then free to ask me