are there any 3rd party libs at all in python that do something on top of webdriver?
I am considering using selenium webdriver in python, but i would really like to use a ui-module based approach. What i mean by that is instead of code that might look like this:
cheese = driver.find_element_by_css_selector("#food span.dairy.aged")
cheese.click()
i want something like (not python!):
ui.Div(uid: "div1", clocator: [id: "div1"]) {
Div(uid: "inner-container", clocator: [id: "div2"]) {
List(uid: "list1", clocator: [tag: "ul"], separator: "li"){
UrlLink(uid: "{all}", clocator: [:])
}
}
}
click 'inner-container'
So I define my UI beforehand, and then write the testcases. If the UI changes, I need to change the UI module definition and not worry about the testcases.
I can hand roll this, but are there any libs for python that do this for me?
There is no existing project that I am aware of that does what you want. One pattern that I’ve been using in my functional tests with Webdriver is to define each logical page as a class. Something like this:
And then use it in in the test like so, where ‘self’ in this case is an instance of unit test :
Using this pattern might get you close to what you want to do. The way a page works is logically contained in the class methods, instead of being endlessly repeated through each functional test.