Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 19, 2022. It is now read-only.

Commit 2ee95bf

Browse files
author
crimier
committed
Completed code in page-objects.rst
1 parent f7b09fe commit 2ee95bf

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

source/page-objects.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Page Objects
55

66
.. note::
77

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
1010
`Github <https://github.com/baijum/selenium-python>`_. Here is an
1111
example implementation of the page objects pattern:
1212
https://github.com/baijum/pitracker/tree/master/test/acceptance
@@ -63,7 +63,7 @@ The ``page.py`` will look like this::
6363
search_text_element = SearchTextElement()
6464

6565
def is_title_matches(self):
66-
pass
66+
return "Python" in self.driver.title
6767

6868
def click_go_button(self):
6969
element = self.driver.find_element(*MainPageLocators.GO_BUTTON)
@@ -73,7 +73,8 @@ The ``page.py`` will look like this::
7373
class SearchResultsPage(BasePage):
7474

7575
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
7778

7879
The ``element.py`` will look like this::
7980

@@ -85,14 +86,14 @@ The ``element.py`` will look like this::
8586
def __set__(self, obj, value):
8687
driver = obj.driver
8788
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)
9091

9192
def __get__(self, obj, owner):
9293
driver = obj.driver
9394
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)
9697
return element.get_attribute("value")
9798

9899
The ``locators.py`` will look like this::

0 commit comments

Comments
 (0)