Helping Information

Discover Web Automation Using Python Selenium.

Discover Web Automation Using Python Selenium.
Web Automation Using Python Selenium.

Let’s dive into this tutorial will make web UI testing easy. we’ll build an easy yet robust web UI test solution using Python, pytest, and Selenium WebDriver. we’ll learn strategies permanently test design also as patterns permanently automation code. Discover Web Automation Using Python Selenium. By the top of the tutorial, you’ll be an internet test automation champ! Your Python test project is often the inspiration for your own test cases, too.

Web Automation will simplify your regular task by setting correct parameters. To make your task easier python selenium framework is used. Ease your daily task.

Discover Web Automation Using Python Selenium WebDriver for Chrome Browser

WebDriver is an open-source tool for automated testing of web apps across many browsers. It provides capabilities for navigating to sites, user input, JavaScript execution, and more. ChromeDriver may be a standalone server that implements the W3C WebDriver standard. ChromeDriver is out there for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS). If you are using windows operating system then you have to download WebDriver for Windows.Download WebDriver from Chrome for Windows.

Installation of Selenium WebDriver

For our test project, we’ll use Selenium WebDriver’s Python bindings with Google Chrome and ChromeDriver. We could use any browser, but let’s use Chrome because (a) it’s a really high market share and (b) its Developer Tools will are available handy later. After downloading the WebDriver for Chrome using the download button provided. Then, you have to extract the file. After extracting the file you will find an application called chromedriver.exe. Run that application and installed it. Verify that ChromeDriver works from the command line:

$ chromedriver
Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

You can download the Python bindings for Selenium from the PyPI page for selenium package. However, a far better approach would be to use pip to put in the selenium package. Python 3.6 has pip available within the standard library. Discover Web Automation Using Python Selenium Using pip, you’ll install selenium like this:

pip install selenium

For Python 3 you can install given as below.

pip3 install selenium

Write your First Web Test

Discover Web Automation Using Python Selenium With WebDriver ready to go, let’s write our first web test! The test will be a simple Facebook login. Facebook is a Social Media platform. Users can enter Email and password in one file and import that file using the import function in python and it will redirect to your Facebook home page, just like you do it regularly. Here I’m giving you sample code for practice purpose only. Discover Web Automation Using Python Selenium first file is myfb.py

from selenium import webdriver
browser =  webdriver.Chrome(executable_path=’C:UsersRahulDownloadsChromeWebDriverchromedriver.exe’)
browser.get(‘https://www.facebook.com/’)

Remember, your executable_path is the location where you have downloaded chrome web driver and in a browser.get(enter the URL you want to test).

The second file for credential.py

def getemail():
return ‘[email protected]
def getpassword():
return ‘yourpassword’

The third file is automate.py

from selenium import webdriver
import credentials
email = credentials.getemail()
pass = cedentials.getpassword()
browser =  webdriver.Chrome(executable_path=’C:UsersRahulDownloadsChromeWebDriverchromedriver.exe’)
def init():
browser.get(‘https://wwww.facebook.com/’)
def login():
browser.find_element_by_id(’email’).send_keys(email)
browser.find_element_by_id(‘pass’).send_keys(pass)
browser.find_element_by_id(‘loginbutton’).click()
init()
login()

To fill user input value into webpage input text field you have to inspect the webpage and find out what data variable used in that webpage and associate that data variables with the variable that we defined in the program. Discover Web Automation Using Python Selenium.

In this post, we take an example of Facebook login with selenium. Here, we automate facebook login by coding in python selenium module. Discover Web Automation Using Python Selenium as we are passing username and password to chrome browser on Facebook page and then it tries to log in using Facebook account.

Check out our another post here.

0 comments / Add your comment below

Leave a Reply

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