Webium: Page Objects In Python (Eng)
-
Upload
uladzimir-franskevich -
Category
Software
-
view
2.231 -
download
2
Transcript of Webium: Page Objects In Python (Eng)
Webium: Page Object в Python
Uladzimir FranskevichQA Automation Team Lead
Wargaming.NET
Prehistory• No suitable alternatives were found in Python• Inspired by HtmlElements (
http://htmlelements.qatools.ru/)
Tool requirements• Extend WebElement – not just wrap it• Ability to describe single & multiple elements
(find_element & find_elements)• Search context support• Lazy element initialization
Alternatives?
Robot Framework Page Objectshttps://github.com/ncbi/robotframework-pageobjects
holmium.corehttps://github.com/alisaifee/holmium.core
wtframeworkhttps://github.com/wiredrive/wtframework
What’s about Webium?
BasePage
• Specify page url• If required set a custom instance of driver• Describe page structure using Find
Find
• by – search strategy• value – search expression• WebElement instance is returned when a
corresponding field is accessed
BasePage - Usage Example
text_field & button are instances of WebElement class
Extending WebElement• Inherit from WebElement• Add or override WebElement class members
Custom Controls Usage
>> Text to search: webium
Extended WebElement with custom property
Findsis used like Find returns a list of elements
Findssupports custom control classes
webium.controls contains some of
most frequent controls!
Containers
Containers
• Ability to search for elements using context• Code reuse among several page objects• Containers are subclasses of WebElement
Containers – Usage example
Logical containers
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/
is_element_present
>> True>> False
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
Parameterized Pages
Parameterized Pages
Dynamic Content Loading• https://pypi.python.org/pypi/waiting/ • Handling WebDriverException
Settings
• webium.settings– wait_timeout = 30– default_search_type = By.ID
• local_webium_settings – to override Webium settings locally
implicitly_wait
• webium.settings.implicit_timeout• 30 seconds by default• Disabled by default for Finds
WebDriver settings• webium.settings.driver_class• Nose plugin for closing browser after tests• Initialize WebDriver out of Webium and pass
its instance to BasePage
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]