webium: page objects in python (eng)

29
Webium: Page Object в Python Uladzimir Franskevich QA Automation Team Lead Wargaming.NET

Upload: uladzimir-franskevich

Post on 08-Feb-2017

2.208 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Webium: Page Objects In Python (Eng)

Webium: Page Object в Python

Uladzimir FranskevichQA Automation Team Lead

Wargaming.NET

Page 2: Webium: Page Objects In Python (Eng)

Prehistory• No suitable alternatives were found in Python• Inspired by HtmlElements (

http://htmlelements.qatools.ru/)

Page 3: Webium: Page Objects In Python (Eng)

Tool requirements• Extend WebElement – not just wrap it• Ability to describe single & multiple elements

(find_element & find_elements)• Search context support• Lazy element initialization

Page 4: Webium: Page Objects In Python (Eng)

Alternatives?

Page 5: Webium: Page Objects In Python (Eng)

Robot Framework Page Objectshttps://github.com/ncbi/robotframework-pageobjects

Page 6: Webium: Page Objects In Python (Eng)

holmium.corehttps://github.com/alisaifee/holmium.core

Page 7: Webium: Page Objects In Python (Eng)

wtframeworkhttps://github.com/wiredrive/wtframework

Page 8: Webium: Page Objects In Python (Eng)

What’s about Webium?

Page 9: Webium: Page Objects In Python (Eng)

BasePage

• Specify page url• If required set a custom instance of driver• Describe page structure using Find

Page 10: Webium: Page Objects In Python (Eng)

Find

• by – search strategy• value – search expression• WebElement instance is returned when a

corresponding field is accessed

Page 11: Webium: Page Objects In Python (Eng)

BasePage - Usage Example

text_field & button are instances of WebElement class

Page 12: Webium: Page Objects In Python (Eng)

Extending WebElement• Inherit from WebElement• Add or override WebElement class members

Page 13: Webium: Page Objects In Python (Eng)

Custom Controls Usage

>> Text to search: webium

Extended WebElement with custom property

Page 14: Webium: Page Objects In Python (Eng)

Findsis used like Find returns a list of elements

Page 15: Webium: Page Objects In Python (Eng)

Findssupports custom control classes

webium.controls contains some of

most frequent controls!

Page 16: Webium: Page Objects In Python (Eng)

Containers

Page 17: Webium: Page Objects In Python (Eng)

Containers

• Ability to search for elements using context• Code reuse among several page objects• Containers are subclasses of WebElement

Page 18: Webium: Page Objects In Python (Eng)

Containers – Usage example

Page 19: Webium: Page Objects In Python (Eng)

Logical containers

Page 20: Webium: Page Objects In Python (Eng)

is_element_present• Standard action in tests • Almost everyone has own

alternative to this function• It is not trivial to do this check right http

://seleniumcamp.com/archive/selenium-camp-2013/materials/mistakes-of-beginners/

Page 21: Webium: Page Objects In Python (Eng)

is_element_present

>> True>> False

Page 22: Webium: Page Objects In Python (Eng)

is_element_present• Method is included in BasePage and in any

container• Parameters:– element_name – class attribute name– just_in_dom – whether to check element

presence in DOM only– timeout – wait for True for specified time

Page 23: Webium: Page Objects In Python (Eng)

Parameterized Pages

Page 24: Webium: Page Objects In Python (Eng)

Parameterized Pages

Page 25: Webium: Page Objects In Python (Eng)

Dynamic Content Loading• https://pypi.python.org/pypi/waiting/ • Handling WebDriverException

Page 26: Webium: Page Objects In Python (Eng)

Settings

• webium.settings– wait_timeout = 30– default_search_type = By.ID

• local_webium_settings – to override Webium settings locally

Page 27: Webium: Page Objects In Python (Eng)

implicitly_wait

• webium.settings.implicit_timeout• 30 seconds by default• Disabled by default for Finds

Page 28: Webium: Page Objects In Python (Eng)

WebDriver settings• webium.settings.driver_class• Nose plugin for closing browser after tests• Initialize WebDriver out of Webium and pass

its instance to BasePage

Page 29: Webium: Page Objects In Python (Eng)

Thanks!Q&A

• Links:– https://github.com/wgnet/webium– http://wgnet.github.io/webium/– https://pypi.python.org/pypi/webium

• Contacts:Uladzimir [email protected] [email protected]