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

Skip to content

Commit 49aa8a8

Browse files
committed
expand introduction and add sections
1 parent d16803c commit 49aa8a8

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

source/page-objects.rst

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ Page Objects
55

66
.. note::
77

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-
`Github <https://github.com/baijum/selenium-python>`_. Here is an
11-
example implementation of the page objects pattern:
8+
Code in this chapter works and is quite self-descriptive, but a
9+
little description wouldn't hurt. If anyone interested, please
10+
send pull request in `Github
11+
<https://github.com/baijum/selenium-python>`_. Here is an example
12+
implementation of the page objects pattern:
1213
https://github.com/baijum/pitracker/tree/master/test/acceptance
1314

14-
This chapter is a tutorial introduction to use page objects design
15-
pattern. Here is a test case which searches for a word in python.org
16-
website and ensure some results are found.
15+
This chapter is a tutorial introduction to page objects design
16+
pattern. A page object represents an area in the web application user
17+
interface that your test is interating. Page objects reduces the
18+
amount of duplicated code and if the user interface changes, the fix
19+
need only changes in one place.
20+
21+
Test case
22+
~~~~~~~~~
23+
24+
Here is a test case which searches for a word in python.org website
25+
and ensure some results are found.
1726

1827
::
1928

@@ -41,6 +50,9 @@ website and ensure some results are found.
4150
if __name__ == "__main__":
4251
unittest.main()
4352

53+
Page object classes
54+
~~~~~~~~~~~~~~~~~~~
55+
4456
The ``page.py`` will look like this::
4557

4658
from element import BasePageElement
@@ -75,6 +87,9 @@ The ``page.py`` will look like this::
7587
#Probably should search for this text in the specific page element, but as for now it works fine
7688
return "No results found." not in self.driver.page_source
7789

90+
Page elements
91+
~~~~~~~~~~~~~
92+
7893
The ``element.py`` will look like this::
7994

8095
from selenium.webdriver.support.ui import WebDriverWait
@@ -95,6 +110,9 @@ The ``element.py`` will look like this::
95110
element = driver.find_element_by_name(self.locator)
96111
return element.get_attribute("value")
97112

113+
Locators
114+
~~~~~~~~
115+
98116
The ``locators.py`` will look like this::
99117

100118
from selenium.webdriver.common.by import By

0 commit comments

Comments
 (0)