@@ -5,8 +5,8 @@ Page Objects
5
5
6
6
.. note ::
7
7
8
- This chaper is a work in progress, right now I don 't have time to
9
- finish it. If anyone interested, please send pull request in
8
+ Code in this chapter works and is quite self-descriptive, but a little description wouldn 't hurt.
9
+ If anyone interested, please send pull request in
10
10
`Github <https://github.com/baijum/selenium-python >`_. Here is an
11
11
example implementation of the page objects pattern:
12
12
https://github.com/baijum/pitracker/tree/master/test/acceptance
@@ -63,7 +63,7 @@ The ``page.py`` will look like this::
63
63
search_text_element = SearchTextElement()
64
64
65
65
def is_title_matches(self):
66
- pass
66
+ return "Python" in self.driver.title
67
67
68
68
def click_go_button(self):
69
69
element = self.driver.find_element(*MainPageLocators.GO_BUTTON)
@@ -73,7 +73,8 @@ The ``page.py`` will look like this::
73
73
class SearchResultsPage(BasePage):
74
74
75
75
def is_results_found(self):
76
- pass
76
+ #Probably should search for this text in the specific page element, but as for now it works fine
77
+ return "No results found." not in self.driver.page_source
77
78
78
79
The ``element.py `` will look like this::
79
80
@@ -85,14 +86,14 @@ The ``element.py`` will look like this::
85
86
def __set__(self, obj, value):
86
87
driver = obj.driver
87
88
WebDriverWait(driver, 100).until(
88
- lambda driver: driver.find_element_by_id (self.locator))
89
- driver.find_element_by_id (self.locator).send_keys(value)
89
+ lambda driver: driver.find_element_by_name (self.locator))
90
+ driver.find_element_by_name (self.locator).send_keys(value)
90
91
91
92
def __get__(self, obj, owner):
92
93
driver = obj.driver
93
94
WebDriverWait(driver, 100).until(
94
- lambda driver: driver.find_element_by_id (self.locator))
95
- element = driver.find_element_by_id (self.locator)
95
+ lambda driver: driver.find_element_by_name (self.locator))
96
+ element = driver.find_element_by_name (self.locator)
96
97
return element.get_attribute("value")
97
98
98
99
The ``locators.py `` will look like this::
0 commit comments