Skip to content

aKumpan/Python_WebDriver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium Webdriver + Python automation example

License badge

This repository contains Selenium Webdriver + Python examples to automate Web Based applications Wikipedia used as example. These examples are open source, released under the terms of Apache 2.0 License.

Code examples

  1. BasePage:
class Page(object):
    def __init__(self, driver):
        self.driver = driver
        self.timeout = 30

    def check_page_title(self, title):
        WebDriverWait(self.driver, self.timeout).until(EC.title_contains(title))

    def find_element(self, *locator):
        return self.driver.find_element(*locator)

    def get_title(self):
        return self.driver.title

    def get_current_url(self):
        return self.driver.current_url
  1. Simple test:
class WikipediaTests(BaseTest):
    SEARCH_TERM = "Software"

    def search_test(self):
        main_page = MainPage(self.driver).open()
        article_page = main_page.search_for(self.SEARCH_TERM)  # searching for SEARCH_TERM

        article_page.check_page_title(self.SEARCH_TERM)  # Verifying that Article page title contains SEARCH_TERM

Usage

In order to use Selenium Webdriver + Python automation example, first of all install Python 3.0+ verison and pip. Latest version available here: Download Python

To run application:

  1. Navigate to the project root folder.
  2. Execute command:
pip install -r requirements.txt
  1. Execute command:
python -m unittest tests.WikipediaTests.WikipediaTests.search_test

About

Selenium Webdriver + Python automation (Copyright © 2017) is a personal project of Anton Kumpan licensed under Apache 2.0 License. Comments, questions and suggestions are always very welcome!

About

Selenium Webdriver + Python automation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages