We may earn an affiliate commission when you visit our partners.
Course image
Raghav Pal

This course is created for complete beginners. 

Get started with Selenium in Python step by step.

If you are a complete beginner on Selenium or Python, this course is for you. Very basic step by step videos to guide you from scratch. 

Read more

This course is created for complete beginners. 

Get started with Selenium in Python step by step.

If you are a complete beginner on Selenium or Python, this course is for you. Very basic step by step videos to guide you from scratch. 

In this course we will learn:

  • How to install Python (Mac & Windows)

  • How to install Selenium

  • How to setup Selenium Python project

  • How to create first test script

  • How to generate reports

  • How to create Automation Framework

  • How to run from command line

  • How to use Jenkins for Continuous Integration

  • How to record & play

  • How to use testing frameworks like PyUnit and PyTest

  • How to use Allure Reports

  • Create an end-to-end Automation Framework from scratch

  • And much more...

Do not worry if you have never used Python or Selenium. I will guide you on every step.Let's Get Started...

Enroll now

What's inside

Learning objectives

  • Create complete automation framework
  • Create automation tests with selenium & python
  • Generate html reports
  • Use jenkins for continuous integration
  • Use git for version control
  • Plan, build and execute test automation with selenium & python
  • Understand the basics of selenium and python automation

Syllabus

About Raghav and this course
A message from Raghav
About Raghav and this course ***Must Watch***
Start with Selenium Python
Read more

How to install Python on Windows

Step by Step for Beginners


Today we will learn:


  1. Check if Python is already installed

  2. Download Python

  3. Install Python

  4. Validate if Python is installed properly

  5. How to uninstall python


Step 1 : Check if python is already installed

python --version


Step 2 : Download Python - https://www.python.org/downloads/windows/


Step 3 : Install Python


Step 4 : Add Python to Path environment variable (if not already added)


Step 5 : Check if Python and Pip are installed

python --version

pip --version


How to Uninstall or Repair Python

References:

https://pip.pypa.io/en/stable/installing/


by : Raghav Pal

How to install Python on MacOS

Step by Step for Beginners



Today we will learn:

  1. Check if Python is already installed

  2. Download Python

  3. Install Python

  4. Validate if Python is installed properly

  5. How to uninstall python


Step 1 : Check if python is already available


Step 2 : Download and install python
https://www.python.org/downloads/


Step 3 : Check if python is installed properly

python --version

pip --version


In case pip is not installed

 sudo easy_install pip


How to uninstall Python

Follow steps in video


by : Raghav Pal

How to install Selenium for Python

Step by Step for Beginners


Today we will learn:

  1. How to install Selenium 

  2. How to uninstall Selenium


by : Raghav Pal

Setting up Selenium with Python
Integrated Development Environment

IDE for Python : PyCharm

Step by Step for Beginners


What is IDE 

Integrated Development Environment


Why we need IDE

Structure
Auto-completion
Debugging
Management


IDE for Python : PyDev

How to install PyDev in Eclipse

Step by Step for Beginners


Step 1 : Eclipse > Help > Eclipse Marketplace

Search for PyDev

Install Pydev and restart Eclipse


Step 2 : Eclipse > Help > Install New Software

  Pydev - http://www.pydev.org/updates

Restart Eclipse 


Step 3 : Goto File > New > Others > Pydev Project

Configure python interpreter


Step 4 : Add python module and write python code



Selenium New Website
New Selenium Wesbite
Start Selenium with Python

First Selenium Python test


Today we will : 

  1. Create a new project in PyCharm

  2. Add Selenium scripts

  3. Add Browser driver

  4. Run and Validate


pip install -U selenium


CODE


import time

from selenium import webdriver

driver = webdriver.Chrome("../drivers/chromedriver.exe")

driver.set_page_load_timeout(10)

driver.get("https://google.com")

driver.find_element_by_name("q").send_keys("Automation step by step")

driver.find_element_by_name("btnK").click()

time.sleep(2)

driver.close()

driver.quit()

print("Test Completed")

How to run selenium python tests on different browsers

Selenium Python testing on Chrome

Step by Step


Today we will : 


  1. How to run test on Chrome 

  2. How to run test on Headless Chrome

  3. How to set Chrome Options


For headless chrome

Chrome browser v59+

ChromeDriver v.2.38+


CODE


from selenium import webdriver

from selenium.webdriver.chrome.options import Options


# chrome_options = webdriver.ChromeOptions()

chrome_options = Options()

chrome_options.add_argument("--headless")

chrome_options.add_argument("--disable-extensions")


driver = webdriver.Chrome(chrome_options=chrome_options, executable_path="../drivers/chromedriver.exe")


driver.get("https://google.com")

print(driver.title)

driver.find_element_by_name("q").send_keys("Automation step by step")

driver.find_element_by_name("btnK").click()

print(driver.title)

driver.close()

driver.quit()

print("Completed")



REFERENCES

http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/

Selenium Python testing on Firefox


Today we will : 

  1. How to run test on Firefox

  2. How to run test on Headless Firefox

  3. How to set Firefox Options


CODE


from selenium import webdriver

import time

from selenium.webdriver.common.keys import Keys


firefox_options = webdriver.FirefoxOptions()

firefox_options.add_argument("--headless")


path = "../drivers/geckodriver.exe"

driver = webdriver.Firefox(executable_path=path, firefox_options=firefox_options)

driver.get("https://google.com")

driver.find_element_by_name("q").send_keys("Automation step by step")

time.sleep(2)

driver.find_element_by_name("btnK").send_keys(Keys.ENTER)

time.sleep(2)

print(driver.title)

driver.close()

driver.quit()


https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Firefox_FirefoxOptions.htm

https://stackoverflow.com/questions/42529853/list-of-firefox-and-chrome-arguments-preferences

Selenium Python testing on IE

Step by Step


Today we will learn :

  1. How to run test on Internet Explorer

  2. How to set Desired Capabilities


CODE

from selenium import webdriver


caps = webdriver.DesiredCapabilities.INTERNETEXPLORER

caps['ignoreProtectedModeSettings'] = True


path = "../drivers/IEDriverServer.exe"

driver = webdriver.Ie(executable_path=path, desired_capabilities=caps)

driver.get("https://google.com")

driver.find_element_by_name("q").send_keys("Abcd")

driver.find_element_by_name("btnK").click()

driver.quit()

print("Completed")


REFERENCES


http://selenium-release.storage.googleapis.com/index.html

https://www.seleniumhq.org/download/

https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities

How to install and use Webdriver Manager
WebDriver Manager | Automatic management of browser drivers for Selenium
How to find web elements

Selenium Python | How to find web elements

Today we will learn :

How to find web elements on web page
---------------------------------------------

Functions in Selenium to find Web Elements
---------------------------------------------

Some Plugins
---------------------------------------------

Useful Tips

---------------------------------------------


Functions to find web element

  • find_element_by_id

  • find_element_by_name

  • find_element_by_class_name

  • find_element_by_css_selector

  • find_element_by_tag_name

  • find_element_by_link_text

  • find_element_by_partial_link_text

  • find_element_by_xpath

Functions to find web elements (list of elements)

  • find_elements_by_id

  • find_elements_by_name

  • find_elements_by_class_name

  • find_elements_by_css_selector

  • find_elements_by_tag_name

  • find_elements_by_link_text

  • find_elements_by_partial_link_text

  • find_elements_by_xpath


References:

https://www.w3schools.com/xml/xpath_syntax.asp

https://www.w3schools.com/html/html_id.asp

Learn Python Basics in a very easy way
  1. Basics

  2. Variables

  3. Syntax

  4. Function

  5. CommandLine

  6. Comments

  7. Numbers

  8. Strings

  9. Input

Python Basics 2| If | Else | Loops
Python Basics 3 | Functions

How to create Classes

How to create Functions

How to create Objects for class

Basic functions

Collections in Python - List | Tuple | Sets |Dictionary

Python Programming | Basics | Collections

Step by Step

LISTS

There are 4 Collection data types in Python

List  |  Tuple  |  Set  |  Dictionary


List    []      ordered | indexed | changeable | duplicates

Tuple   ()     ordered | indexed | unchangeable | duplicates

Set     {}      unordered | unindexed | no duplicates

Dictionary  {K:V} unordered | changeable | indexed | no duplicates


CODE - List


my_list = ["Tokyo", "London", "New York"]

print(my_list)

print(my_list[2])


my_list[2] = "New Delhi"

print(my_list)


for val in my_list:

    print(val)


print(len(my_list))


my_list.append("Boston")

print(my_list)

my_list.insert(4,"Durham")

print(my_list)


my_list.remove("Tokyo")

print(my_list)

my_list.pop(1)

print(my_list)


del my_list[1]

print(my_list)


my_list.clear()

print(my_list)


fruits = ["apples", "oranges", "cherry"]

print(fruits)

fruits.reverse()

print(fruits)


my_list_2 = ["apples", 1,2,3.0]

my_list_3 = ["apples", [1,2,3], ['a','b','c']]

print(my_list_3[1][1])

Python Programming | Basics | Collections

Step by Step


TUPLE


There are 4 Collection data types in Python

List  |  Tuple  |  Set  |  Dictionary


List    []      ordered | indexed | changeable | duplicates

Tuple   ()     ordered | indexed | unchangeable | duplicates

Set     {}      unordered | unindexed | no duplicates

Dictionary  {K:V} unordered | changeable | indexed | no duplicates


Code - Tuple


my_tuple = ("Apples", "Oranges", "Grapes")


print(my_tuple)

print(my_tuple[1])

print(my_tuple[-1])

print(my_tuple[0:2])


for val in my_tuple:

    print(val)


# my_tuple[3] = "Cherry"

# del my_tuple


print(len(my_tuple))


my_tuple_2 = ("Banana",(1,2,3),["Tokyo","New Delhi"])

print(my_tuple_2)

print(my_tuple_2[2][1])


my_tuple_2[2][1] = "New York"

print(my_tuple_2)


print("Banana" in my_tuple_2)   # True

print("Cherry" in my_tuple_2)   # False


Python Programming | Basics | Collections

Step by Step


SETS


There are 4 Collection data types in Python

List  |  Tuple  |  Set  |  Dictionary


List    []      ordered | indexed | changeable | duplicates

Tuple   ()     ordered | indexed | unchangeable | duplicates

Set     {}      unordered | unindexed | no duplicates

Dictionary  {K:V} unordered | changeable | indexed | no duplicates


Code - Sets


my_set = {"Chalk", "Duster", "Board"}

print(my_set)


for x in my_set:

    print(x)


print("Chalk" in my_set)


my_set.add("Pen")

print(my_set)

my_set.update(["Pencil", "Eraser"])

print(my_set)


len(my_set)


my_set.remove("Pencil")

print(my_set)

my_set.discard("Pen")

print(my_set)

# my_set.remove("Pencil")

my_set.discard("Pen")


my_set.pop()

my_set.clear()

print(my_set)


del my_set


my_set_2  = {"Apples", 1,2, (3,4,5)}

print(my_set_2)


my_list = [1,2,3]

print(my_list)

my_set_3 = set(my_list)

print(my_set_3)


# UNION | INTERSECTION | DIFF | SYMMETRIC DIFF

A = {'A', 'B', 1, 2, 3}

B = {'B', 'C', 3, 4, 5}


print(A.union(B))

print(A | B)


print(A.intersection(B))

print(A & B)


print(A.difference(B))

print(A - B)


print(A.symmetric_difference(B))

print(A ^ B)

Python Programming | Basics | Collections

Step by Step


DICTIONARY


There are 4 Collection data types in Python

List  |  Tuple  |  Set  |  Dictionary


List    []      ordered | indexed | changeable | duplicates

Tuple   ()     ordered | indexed | unchangeable | duplicates

Set     {}      unordered | unindexed | no duplicates

Dictionary  {K:V} unordered | changeable | indexed | no duplicates


Code - Dictionary


my_dict = {

    "class" :   "animal",

    "name"  :   "giraffe",

    "age"   :   10

}


print(my_dict)

print(my_dict["name"])

print(my_dict.get("name"))

print(my_dict.values())


for x in my_dict:

    print(my_dict[x])


for x,y in my_dict.items():

    print(x, y)


my_dict["name"] = "elephant"

print(my_dict)


my_dict["color"] = "grey"

print(my_dict)


my_dict.pop("color")

print(my_dict)

my_dict.popitem()

print(my_dict)


del my_dict["class"]

print(my_dict)


my_dict.clear()

print(my_dict)


del my_dict

How to create unit tests in Python
How to create Unit Tests with PyUnit (Standard unit testing framework for Python

Selenium Python Unit Testing Demo

Step by Step


Today we will learn:

  1. How to create Selenium unit tests

  2. Command-line execution

References

https://docs.python.org/3/library/unittest.html#unittest.TestCase.debug

https://stackoverflow.com/questions/1322575/what-numbers-can-you-pass-as-verbosity-in-running-python-unit-test-suites

How to generate html reports

Selenium Python - How to create HTML REPORT

Step by Step


Today we will learn:


  1. How to install HTMLTestRunner

  2. How to generate html reports for Selenium unit tests

Step 1 : Install Html Test Runner

pip install -U html-testRunner


Step 2 : Add HTML Test runner in unit test file



Sample Code:


import unittest

from selenium import webdriver

import HtmlTestRunner


class MyTestCase(unittest.TestCase):


    @classmethod

    def setUpClass(cls):

        cls.driver = webdriver.Chrome(executable_path="../drivers/chromedriver.exe")

        cls.driver.implicitly_wait(10)

        cls.driver.maximize_window()



    def test_search_1(self):

        self.driver.get("http://google.com")

        self.driver.find_element_by_name("q").send_keys("Automation step by step")

        self.driver.find_element_by_name("btnK").click()

        x = self.driver.title

        print(x)

        self.assertEqual(x, "Automation step by step - Google Search")


    def test_search_2(self):

        self.driver.get("http://google.com")

        self.driver.find_element_by_name("q").send_keys("Raghav Pal")

        self.driver.find_element_by_name("btnK").click()

        x = self.driver.title

        print(x)

        self.assertEqual(x, "Raghav Pal - Google Search")


    @unittest.skip("This is a skipped test.")

    def test_skip(self):

        """ This test should be skipped. """


    @classmethod

    def tearDownClass(cls):

        cls.driver.close()

        cls.driver.quit()


if __name__ == '__main__':

    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:/Users/Administrator/PycharmProjects/Selenium/reports'),verbosity=2)


Selenium Python - How to view REPORTS in PyCharm

Step by Step


Today we will learn:

  1. How to view and export unit test results in PyCharm HTML

References:

https://www.jetbrains.com/help/idea/test-runner-tab.html

How to use waits

Selenium Python - WAITS

Step by Step


Today we will learn:

Why to use waits in Selenium

What are Implicit & Explicit waits

How to use Implicit and Explicit waits


Why are waits required:

  • All elements on a web page may not load at the same time

  • Required for websites using Ajax and Javascript

  • To avoid ElementNotVisible exception from Selenium


Selenium web driver has 2 types of waits

Implicit - poll the DOM for a specific duration to locate an element 500ms until timeout

10 sec - 

Explicit - waits for a certain condition to occur before proceeding with next step


Sample Code : 


from selenium import webdriver

from selenium.webdriver.support.ui import  WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.by import By

from selenium.common.exceptions import TimeoutException


driver = webdriver.Chrome(executable_path="../drivers/chromedriver.exe")

# Implicit Waits

# driver.implicitly_wait(10)


driver.get("https://google.com")


driver.find_element_by_name("q").send_keys("Automation")


wait = WebDriverWait(driver, 10)

try:

    element = wait.until(EC.element_to_be_clickable((By.NAME,"btnK1")))

    print("element is clickable")

except TimeoutException:

    print("element is not clickable")

    exit(1)

    

element.click()


# driver.find_element_by_name("btnK").click()


print("Test Completed")

driver.close()

driver.quit()



References:

https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html

https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Support_UI_ExpectedConditions.htm

A small sample project

Selenium Python

Sample Project


  1. Create a test for Google Search

  2. Add implicit wait of 10 sec

  3. Maximise window

  4. Create Unit Tests

  5. Add HTML reporting library

  6. Run from command line


Code:

from selenium import webdriver

import unittest

import HtmlTestRunner


class GoogleSearch(unittest.TestCase):


    @classmethod

    def setUpClass(cls):

        cls.driver = webdriver.Chrome(executable_path='../drivers/chromedriver.exe')

        cls.driver.implicitly_wait(10)

        cls.driver.maximize_window()


    def test_search_automationstepbystep(self):

        self.driver.get("https://google.com")

        self.driver.find_element_by_name("q").send_keys("Automation Step by Step")

        self.driver.find_element_by_name("btnK").click()


    def test_search_raghav(self):

        self.driver.get("https://google.com")

        self.driver.find_element_by_name("q").send_keys("Raghav Pal")

        self.driver.find_element_by_name("btnK1").click()


    @classmethod

    def tearDownClass(cls):

        cls.driver.close()

        cls.driver.quit()

        print("Test Completed")



if __name__ == '__main__':

    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:/Users/Administrator/PycharmProjects/Selenium/reports'))

How to use Page Object Model principles and design tests

Selenium Python - Page Object Model (POM)

Step by Step



Today we will learn:

    1. What is POM

    2. Why to use POM

    3. How to implement POM in selenium python project

    4. Practical Hands-On


https://opensource-demo.orangehrmlive.com/



What is POM:

It is a process where we create a class for each page of the application

This page contains the element locators for that page and action methods.



  • POM stands for Page Object Model

  • Page Object refers to the objects of the web page (section) that our test is interacting with

  • In POM we create separate classes for storing all objects and the actions to be taken on that objects

    Locators and methods are kept separate from test scripts

  • This helps in
    - maintenance
    - less rework
    - better & understandable code
    - In case of changes, fix needs to be done at one place only
    - avoids duplicate code
    - stable and reusable



Step 1 : Create 2 folders : Tests, Pages


Step 2 : Create a simple test 


Step 3 : Convert to unit test


Step 4 : Implement Page Object Model
Identify all objects and actions methods on the page and create a class for each web page


Step 5 : Import the page classes in the test class


Step 6 : Create object for page classes to access methods and create the tests


Step 7 : Run & Validate


Page Object Model | Part 2 | Basics
Page Object Model | Part 3 | Command-line & Reports
A small sample project using page object model

Selenium Python

Small Sample Project 

(POM | Unit Test | HTML Reports)


Step by Step


We will do this hands-on:

    1. Create a simple login test

    2. Implement unit testing

    3. Implement Page Object Model

    4. Separate test scripts and objects

    5. Create a separate class for Locators

    6. Run from command line

    7. Add HTML Reports


Python

IDE - PyCharm

Python lib - selenium

                        Html test runner


https://pypi.org/project/selenium/

https://pypi.org/project/html-testRunner/

https://opensource-demo.orangehrmlive.com/


for reference

# import sys

# import os

# sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))


How to run from commandline
Run from command-line with nested folder imports
How to record your python selenium tests
How to record tests
PyTest - Testing Framework for Python

Selenium Python  | PyTest


Today we will learn:

What is PyTest
—————————————————
How to install PyTest
—————————————————
How to use PyTest with Selenium scripts
—————————————————
How to run tests using PyTest
—————————————————


test_*.py

*_test.py


Note

File name :  test_*.py or *_test.py

Class name should start with Test

https://docs.pytest.org/en/latest/contents.html


  1. Create a simple test script

  2. Install Pytest
    pip install -U pytest
    pytest --version

  3. Rename python file to add test_

  4. Create 3 methods: setup, test, teardown

  5. Run from terminal
    python -m pytest
    py.test
    pytest
    pytest filename
    pytest -v


Fixtures - used to manage tests in PyTest


Function

Class

Module

Session


Note

File name :  test_*.py or *_test.py

Class name should start with Test

https://docs.pytest.org/en/latest/contents.html

PyTest | How to skip tests


How to skip

How to skip with condition (skip)

How to deselect test


@pytest.mark.skip

@pytest.mark.skip(reason=“”)


pytest -v -rxs

pytest -k funcName -v


@pytest.mark.name

pytest -m name


https://docs.pytest.org/en/latest/skipping.html

PYTEST | How to parameterise tests
PYTEST | How to generate HTML Reports
PYTEST | Self Contained HTML Reports
ALLURE REPORTING

Allure Reports 

Selenium Python


Today we will learn:

What is allure report

How to install allure report

How to generate allure reports with pytest


http://allure.qatools.ru/

https://docs.qameta.io/allure/


pip install allure-pytest

pytest --alluredir=/tmp/my_allure_results

allure serve /tmp/my_allure_results


How to use VCS GitHub

How to integrate PyCharm with GitHub

How to use PyCharm with GitHub


Today we will learn:

1. How to create GitHub repository

2. How to integrate GitHub with PyCharm

3. Upload Project on GitHub

4. Push, Pull, Manage with GitHub VCS


References

https://www.jetbrains.com/help/pycharm/manage-projects-hosted-on-github.html

How to remove Project from GitHub
JENKINS CI

How to run from command line


python filename

py.test

py.test filename

pytest

pytest filename

pytest -v

python -m pytest


How to run from Jenkins

Python Selenium


Today we will learn:

Install & Setup Jenkins

Create Jenkins Job

Run & Validate

How to create Allure Reports from Jenkins
Some useful Practical Tips

Pycharm

How to create a virtual environment for a project


What is Python virtual environment (venv)
_________________________________________________

Create a new project with separate virtual env
_________________________________________________

How to change python interpreter for the project
_________________________________________________

How to create a new virtual env
_________________________________________________

How to add packages in a virtual env
_________________________________________________


References

https://docs.python.org/3/library/venv.html


Learn how to create an end-to-end automation framework step by step

Selenium Python Project

PyCharm | POM | PyTest | Allure Reports | Git | Jenkins

from scratch


Python

Pycharm IDE

====== BASIC SETUP =======


Step 1 : Pycharm - create new project with virtual env
—————————————————————————

Step 2 : Settings > Project > Interpreter > add
selenium
—————————————————————————

Step 3: Create 6 folders:
tests
pages
drivers
utils
reports
screenshots
—————————————————————————

Step 4 : Under drivers folder add driver exe for browsers
chrome
firefox…
—————————————————————————

Step 5 : Under tests folder create a new python file (login_test.py)
—————————————————————————

Step 6 : Create a simple login test.
run & validate

https://opensource-demo.orangehrmlive.com/


—————————————————————————


====== PYTEST SETUP =======


Step 7 : Add pytest package -
Settings > Project > Interpreter > add
—————————————————————————

Step 8 : Create functions (pytest)
*** take care of naming convention as per pytest ***

test_*.py. OR *_test.py
test_setup
test_login
test_logout
Add pytest fixture to test_setup

Run & validate


@pytest.fixture(scope="session")

—————————————————————————

Step 9 : Create class TestLogin():
add @pytest.fixture(scope="class")
Run & Validate
—————————————————————————

====== PAGE OBJECT MODEL (POM) SETUP =======


Step 10 : Under pages folder create python file to create classes for pages
—————————————————————————

Step 11 : Add the page objects and actions in respective classes
—————————————————————————

Step 12 : Create objects for pages in test script and use the functions
Run & Validate


====== PAGE OBJECT MODEL (POM) SETUP COMPLETED =======

Step 13 : In utils folder create python file utils and add constants

URL         =   "https://opensource-demo.orangehrmlive.com/"
USERNAME    =   "Admin"
PASSWORD    =   "admin123"

In tests
from utils import utils as utils
—————————————————————————

Step 14 : Add package pytest-html and show html reports
--html
--self-contained-html
—————————————————————————

Step 15 : Add conftest.py
Put the setup teardown here
Remove setup and yield from test class

@pytest.fixture(scope="class")
def test_setup(request):
from selenium import webdriver
# global driver
driver = webdriver.Chrome(executable_path="C:/Users/PycharmProjects/
AutomationFramework/drivers/chromedriver.exe")
  driver.implicitly_wait(5)
driver.maximize_window()
request.cls.driver = driver
  yield
driver.close()
driver.quit()
  print("Test Completed")


add pytest fixture on login_test class
@pytest.mark.usefixtures("test_setup")

Run & Validate

References:
https://stackoverflow.com/questions/34466027/in-py-test-what-is-the-use-of-conftest-py-files


—————————————————————————


Step 16 : In conftest.py create function to get browser name from arguments
https://stackoverflow.com/questions/40880259/how-to-pass-arguments-in-pytest-by-command-line

def pytest_addoption(parser):
parser.addoption("--browser", action="store", default="chrome", help="Type in browser name e.g. chrome OR firefox")

  browser = request.config.getoption("--browser")
    if browser == 'chrome':
         driver = webdriver.Chrome()
—————————————————————————



====== ALLURE REPORTS ======


Step 17 : Add allure reports package
Run with allure reports

Add assertion & validate
x = driver.title
assert x == "abc"
—————————————————————————

Step 18 : Add try except block

try:

except AssertionError as error:
print("Assertion error occurred")
print(error)
raise

except:
print("Some exception occurred")

  else:
print("No exceptions occurred")

finally:
print("This block will always execute | Close DB")

References:
https://realpython.com/python-exceptions/


—————————————————————————

Step 19 : Add statements to attach screenshot in allure reports

import allure

allure.attach(self.driver.get_screenshot_as_png(), name="screenshot",
attachment_type=allure.attachment_type.PNG)

To get current timestamp
import moment
test
import moment
x = moment.now().strftime("%H-%M-%S_%m-%d-%Y")
print(x)

Add function to store screenshot physically
driver.get_screenshot_as_file("C:/Users//AutomationFramework/screenshots/"+screenshotName+".png")

Add a function to get test name

To get test name
https://www.stefaanlippens.net/python_inspect/
def whoami():
return inspect.stack()[1][3]

currTime = moment.now().strftime("%H-%M-%S_%m-%d-%Y")
testName = utils.whoami()
screenshotName = testName+"_"+currTime

Run & Validate with allure reports
—————————————————————————


====== Git & GitHub =====

Step 20 : Add to GitHub
Connect to GitHub account on pycharm
VCS > Import Into Version Control > Share project on GitHub

A new user can now download or clone this project


https://github.com/Raghav-Pal/PythonAutomationFramework_1.git
—————————————————————————

====== Jenkins =====

Step 21 : Download and Setup Jenkins
Add a new Jenkins Job
In Job:
Pull project from GitHub
Run tests
Publish Allure Reports
—————————————————————————

Step 22 : Create Jenkins Pipeline


Pipeline - sequence of jobs chained together

BUILD > DEPLOY > TEST > RELEASE


—————————————————————————

Step 23 : Run the complete project from jenkins
—————————————————————————


=========================================

All the best & Keep learning

Raghav Pal

=========================================

Troubleshooting TIPS
Automation Framework Part 8
Automation Framework Part 9

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Explores Python and Selenium, which are standard in the industry
Teaches Python and Selenium, which helps learners automate tests with Selenium and Python
Examines continuous integration, which is highly relevant to software development
Taught by Raghav Pal, who is recognized for their work in test automation with Selenium
Develops skills in writing and executing automated tests, which are core skills for software testing
Offers hands-on labs and interactive materials, which enhances the learning experience

Save this course

Save Selenium Python - Step by Step for Beginners with Framework to your list so you can find it easily later:
Save

Reviews summary

Comprehensive selenium python course

According to students, this Selenium Python course is highly recommended as it provides a comprehensive overview of the subject matter. Learners appreciate the in-depth coverage of topics, from basic concepts to advanced techniques like framework implementation. The engaging assignments and helpful instructor make it an enjoyable and effective learning experience.
Assignments help reinforce learning.
"Loved it."
Instructor is knowledgeable and responsive.
"Raghav explained very well..."
"we appreciate your course and responses."
Covers a wide range of topics, from fundamentals to advanced techniques.
"Great course, touching all phases from element inspection deploying."
"This Selenium Python course is highly recommended as it provides a comprehensive overview of the subject matter."
"Raghav explained very well, this is one of the best courses to get an idea from A to Z..."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Selenium Python - Step by Step for Beginners with Framework with these activities:
Review Git and GitHub
Review the basics of Git and GitHub to ensure you have the necessary skills to complete the projects and activities in this course.
Browse courses on Git
Show steps
  • Review the Git documentation
  • Create a GitHub account
  • Create a local Git repository
  • Add, commit, and push changes to GitHub
Watch tutorials on Selenium
Enhance your understanding of Selenium by watching tutorials and videos that demonstrate its features and usage.
Browse courses on Selenium
Show steps
  • Find tutorials on Selenium
  • Watch the tutorials
  • Take notes on important concepts
Solve Python coding problems
Practice writing Python code by solving coding problems on platforms like LeetCode or HackerRank.
Browse courses on Python
Show steps
  • Choose a platform for solving coding problems
  • Select a difficulty level
  • Solve coding problems
  • Review your solutions
One other activity
Expand to see all activities and additional details
Show all four activities
Build a Selenium project
Apply your Selenium skills by building a project that automates a web-based task, such as testing a website or scraping data.
Browse courses on Selenium
Show steps
  • Identify a project idea
  • Design the project
  • Implement the project using Selenium
  • Test and refine the project

Career center

Learners who complete Selenium Python - Step by Step for Beginners with Framework will develop knowledge and skills that may be useful to these careers:
Machine Learning Engineer
A machine learning engineer is responsible for developing and deploying machine learning models. They use a variety of machine learning algorithms to train models that can make predictions or classifications based on data. This course can help you build a foundation in Python, which is a popular programming language used for machine learning. You will learn how to use Python to import data, clean and prepare data for analysis, and use machine learning algorithms to train models. This knowledge will be valuable if you are interested in a career as a machine learning engineer.
Data Scientist
A data scientist is responsible for collecting, cleaning, and analyzing data to identify trends and patterns. They use this information to help businesses make better decisions. This course can help you build a foundation in Python, which is a popular programming language used for data science. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use statistical techniques to identify trends and patterns. This knowledge will be valuable if you are interested in a career as a data scientist.
Automation Tester
An automation tester is responsible for testing software applications to ensure that they are working as expected. They use a variety of testing tools and techniques to identify and fix bugs. This course can help you build a foundation in Python, which is a popular programming language used for automation testing. You will learn how to use Python to write test scripts, create test plans, and execute tests. This knowledge will be valuable if you are interested in a career as an automation tester.
Data Analyst
A data analyst is responsible for collecting, cleaning, and analyzing data to identify trends and patterns. They use this information to help businesses make better decisions. This course can help you build a foundation in Python, which is a popular programming language used for data analysis. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use statistical techniques to identify trends and patterns. This knowledge will be valuable if you are interested in a career as a data analyst.
Web Developer
A web developer is responsible for designing and developing websites. They work with a variety of programming languages and technologies to create websites that are both functional and visually appealing. This course can help you build a foundation in Python, which is a popular programming language used for web development. You will learn how to use Python to create web applications, work with databases, and deploy websites to the internet. This knowledge will be valuable if you are interested in a career as a web developer.
Data Engineer
A data engineer is responsible for designing, building, and maintaining data pipelines. They work with a variety of data sources and technologies to create data pipelines that can collect, process, and store data. This course can help you build a foundation in Python, which is a popular programming language used for data engineering. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use data engineering tools to create data pipelines. This knowledge will be valuable if you are interested in a career as a data engineer.
DevOps Engineer
A DevOps engineer is responsible for bridging the gap between development and operations teams. They work to ensure that software is deployed and maintained efficiently and reliably. This course can help you build a foundation in Python, which is a popular programming language used for DevOps. You will learn how to use Python to automate tasks, provision infrastructure, and deploy software. This knowledge will be valuable if you are interested in a career as a DevOps engineer.
Business Analyst
A business analyst is responsible for analyzing business processes and identifying opportunities for improvement. They work with a variety of stakeholders to gather requirements, develop solutions, and implement changes. This course can help you build a foundation in Python, which is a popular programming language used for business analysis. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use statistical techniques to identify trends and patterns. This knowledge will be valuable if you are interested in a career as a business analyst.
Software Engineer
A software engineer is responsible for designing, developing, and maintaining software applications. They work with a variety of programming languages and technologies to create software that meets the needs of users. This course can help you build a foundation in Python, which is one of the most popular programming languages used today. You will learn how to use Python to write scripts, create GUIs, and work with databases. This knowledge will be valuable if you are interested in a career as a software engineer.
Software Developer
A software developer is responsible for designing, developing, and maintaining software applications. They work with a variety of programming languages and technologies to create software that meets the needs of users. This course can help you build a foundation in Python, which is one of the most popular programming languages used today. You will learn how to use Python to write scripts, create GUIs, and work with databases. This knowledge will be valuable if you are interested in a career as a software developer.
Computer Scientist
A computer scientist is responsible for studying the theory and practice of computation. They work on a variety of topics, including algorithms, data structures, and programming languages. This course can help you build a foundation in Python, which is a popular programming language used in computer science. You will learn how to use Python to write scripts, create GUIs, and work with databases. This knowledge will be valuable if you are interested in a career as a computer scientist.
IT Consultant
An IT consultant is responsible for providing advice and guidance to organizations on how to use IT to improve their business operations. They work with a variety of stakeholders to identify opportunities for improvement and develop solutions. This course may be helpful if you are interested in a career as an IT consultant. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use statistical techniques to identify trends and patterns. This knowledge will be valuable if you are interested in a career as an IT consultant.
Product Manager
A product manager is responsible for defining, developing, and launching products. They work with a variety of stakeholders to gather requirements, develop roadmaps, and track progress. This course may be helpful if you are interested in a career as a product manager. You will learn how to use Python to import data from a variety of sources, clean and prepare data for analysis, and use statistical techniques to identify trends and patterns. This knowledge will be valuable if you are interested in a career as a product manager.
Project Manager
A project manager is responsible for planning, executing, and closing projects. They work with a variety of stakeholders to ensure that projects are completed on time, within budget, and to the required quality. This course may be helpful if you are interested in a career as a project manager. You will learn how to use Python to automate tasks, create project plans, and track progress. This knowledge will be valuable if you are interested in a career as a project manager.
IT Manager
An IT manager is responsible for planning, directing, and coordinating the IT resources of an organization. They work with a variety of stakeholders to ensure that IT systems are aligned with the business needs of the organization. This course may be helpful if you are interested in a career as an IT manager. You will learn how to use Python to automate tasks, create project plans, and track progress. This knowledge will be valuable if you are interested in a career as an IT manager.

Reading list

We've selected seven books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Selenium Python - Step by Step for Beginners with Framework.
Collection of recipes that demonstrate how to use Selenium WebDriver to test web applications.
Provides a thorough overview of Cucumber, a tool that facilitates behavior-driven development.
Great introduction to Python programming for beginners. It covers essential topics such as variables, data types, and control flow. While it is not specifically about Selenium, it provides a strong foundation for understanding the code examples and concepts in the course.
Provides a comprehensive overview of Python for data analysis using libraries such as Pandas, NumPy, and Jupyter. While it is not directly related to Selenium, it provides a good foundation for understanding the data handling and analysis aspects of automated testing.
Great guide to agile testing principles and practices. It good choice for learners who want to learn more about agile testing.
Classic guide to design patterns. It good choice for learners who want to learn how to write more reusable and maintainable code.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Selenium Python - Step by Step for Beginners with Framework.
Selenium WebDriver + Java. Complete step by step course.
Most relevant
Selenium WebDriver 4 With Python - Novice To Ninja [2024]
Most relevant
POSTMAN API Testing - Step by Step for Beginners
Most relevant
Groovy Fundamentals For Testers - Step By Step
Most relevant
Learn Cucumber BDD with Java -MasterClass Selenium...
Most relevant
Selenium WebDriver with Java -Basics to...
Most relevant
Advanced Selenium WebDriver with Java and TestNG
Most relevant
Create a Website from Scratch using HTML CSS step by step
Most relevant
Robot Framework Test Automation - Level 1 ( Selenium )
Most relevant
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser