Giter Site home page Giter Site logo

python-automation's Introduction

python-automation

A short tutorial to automate web UI testing with Python and Selenium

Installation

  1. Download python
  2. Download Python Selenium bindings
  3. Download drivers for your favorite browser

Contents

  1. What is automated testing?
  2. Python Selenium bindings
  3. Locating elements in the HTML DOM
  4. Navigating through pages
  5. Waits

Exercise 0: Test your setup

Once you have installed python, python-selenium bindings and the web driver, let's test if the setup is complete

    from selenium import webdriver
    import time
    driver= webdriver.Chrome()
    driver.get('http://seleniumhq.org')
    time.sleep(2)
    driver.close()

Exercise 1: Locating elements by ID

  • Download the file html_code_01
  • Use the path of this file in your automation script and locate the element by ID loginForm

Exercise 2: Locating elements by name

  • Download the file html_code_01
  • Use the path of this file in your automation script and locate the element by name username

Exercise 3: Locating elements by xpath

  • Download the file html_code_01
  • Use the path of this file in your automation script and locate the login form element using relative xpath, absolute xpath and using xpath with an attribute

Exercise 4: Locate elements by class name

  • Download the file html_code_01
  • Use the path of this file in your automation script and locate the element by class name content

Challenge 1: Locate elements in the DOM

  1. Go to http://www.seleniumhq.org/
  2. Locate the element by id q
  3. Locate the element by name q
  4. Locate the element heading What is Selenium? by xpath
  5. Find element by class selenium-sponsors

Exercise 5: Perform a simple search

Exercise 6: Filling forms

  • Download the file html_code_02
  • Use the path of this file in your automation script
  • Locate the select element by name numReturnSelect and select values by index, visible text and value
  • Submit the selection made

Exercise 7: Drag and Drop

Challenge 2: Navigate through a web page

  1. Go to https://wiki.python.org/moin/FrontPage
  2. Perform a Search for the text Beginner
  3. In the left side menubar, change the value of the select from 'More Options' to 'Raw Text'

Exercise 8: Explicit wait

  • Navigate to http://www.python.org
  • Add an explicit wait of 10 seconds for the element with id start-shell

Exercise 9: Implicit wait

  • Navigate to http://www.python.org
  • Add an implicit wait of 10 seconds for the element with id start-shell

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.