GithubHelp home page GithubHelp logo

sumankumar01 / seleniumwithpython Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6.53 MB

Automation with Selenium And Python

Python 98.00% PowerShell 0.40% Batchfile 0.03% HTML 1.58%
python selenium pythonselenium unittest htmltestrunner allure-report pytest suitescript

seleniumwithpython's Introduction

SeleniumWithPython

Automation with Selenium And Python

IDE- Pycharm

1 -> Install selenium using cmd prompt.

 C:\Users\kumar>pip install selenium
 C:\Users\kumar>pip list
          Package    Version
          ---------- -------
          pip        20.0.2
          pytz       2019.3
          selenium   3.141.0
          setuptools 41.2.0
          urllib3    1.25.9

2 -> Set the driver path

   Way 1:
     driver = webdriver.Chrome(executable_path=r"C:\Users\kumar\AppData\Local\Programs\Python\Python38-32\Scripts\chromedriver.exe")
      driver.get("http://www.newtours.demoaut.com/")
   Way 2: 
       i) Simply paste the chromedriver.exe under C:\Users\kumar\AppData\Local\Programs\Python\Python37\Scripts
       ii) Now write the simple code as below:
            driver=webdriver.Chrome()
            driver.get("http://www.newtours.demoaut.com/")    

3 -> Python unit Testing Framework

    1. Pytest
    2. Nose Test
    3. Unittest

        3 -> Html report using UnitTest and HtmlReporter

Image description

4 -> Generate allure Report. downloads the allure zip file and set the environment variable https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.10.0/ install the allure pip install allure-pytest

   import pytest

import unittest import HtmlTestRunner from HtmlTestRunner import HTMLTestRunner import allure

@allure.story('Your Story here') @allure.feature('Your Feature here') class CodeVlidation(unittest.TestCase):

@classmethod
def setUpClass(cls):
    print('Executed Before the all the method executed in class')

@classmethod
def tearDownClass(cls):
    print('xecuted after the all the method executed in class')


def setUp(self):
    print("Setup the environment")
def tearDown(self):
    print("cleaning the environment")

def testcase1(self):

    print("running the test case1")
    self.assertEqual(2, 2)

def testcase2(self):
    print("running the test case2")
    self.assertEqual(2, 3)

if name == 'main':

testList = [CodeVlidation]
testLoad = unittest.TestLoader()

TestList = []
for testCase in testList:
    testSuite = testLoad.loadTestsFromTestCase(testCase)
    TestList.append(testSuite)

newSuite = unittest.TestSuite(TestList)
runner = unittest.TextTestRunner()
runner=HTMLTestRunner(output='example_dir')
runner.run(newSuite)

then run from cmd D:\import\UnitTestPython>python -m pytest UnitTest12345.py --alluredir ./results D:\import\UnitTestPython>allure serve ./results/
https://pythonallure.blogspot.com/ Image description

seleniumwithpython's People

Contributors

sumankumar01 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.