In this series, We going to learn about the create a Test Suite in the Python. Let’s not waste much of the time lets start as quickly as possible.
Things you know before.
1. Selenium – Testing Framework
2. Python – Basic Python Syntax. – Please install it before proceeding.
3. Brain 😛
About Selenium :
Installing Python bindings for Selenium
Go to Command prompt or Terminal in the Mac and Type.
Make sure pip is installed on your system.(If not you can install it using this link here)
pip install selenium
It will install the python binding for the selenium to your system.
Step 1 : Running Selenium Server and Install Python Selenium bindings
Let’s run the Selenium Server that listens to our command/Test cases written python and execute them in the browser. Make sure java is installed on your system and its available in the path. If not follow this tutorial. And set up to path here
Download – Selenium server here.
Run the Selenium Server with this command.
java -jar selenium-server-standalone-3.x.x.jar
You will see something like this on the command line.
Selenium Server is up and Running.
Step 2 : Creating a Basic Test in the Selenium with Python and Run it.
Create a File in the Pycharm ( Python Editor) e.g I have made a Folder structure for the upcoming tutorials also. So This part is Part 1 and I have one file HelloWorld.py that will have the code for the First Test case in python.
In the File, we are going
1. Import the selenium web driver.
2. Create a driver object from FirefoxDriver Class and Open the Borwser.
3. Use get method to go to the URL.
4. Assert the title and Close the Brower.
Run the Test by
from selenium import webdriver
driver = webdriver.Firefox()
assert "Python" in driver.title
File run using python:
So we have successfully run our first Test, Let’s move to the other Tutorial in the Next Part2.
Hope to see you guys in the next part.