@@ -5,15 +5,24 @@ Page Objects
5
5
6
6
.. note ::
7
7
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:
12
13
https://github.com/baijum/pitracker/tree/master/test/acceptance
13
14
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.
17
26
18
27
::
19
28
@@ -41,6 +50,9 @@ website and ensure some results are found.
41
50
if __name__ == "__main__":
42
51
unittest.main()
43
52
53
+ Page object classes
54
+ ~~~~~~~~~~~~~~~~~~~
55
+
44
56
The ``page.py `` will look like this::
45
57
46
58
from element import BasePageElement
@@ -75,6 +87,9 @@ The ``page.py`` will look like this::
75
87
#Probably should search for this text in the specific page element, but as for now it works fine
76
88
return "No results found." not in self.driver.page_source
77
89
90
+ Page elements
91
+ ~~~~~~~~~~~~~
92
+
78
93
The ``element.py `` will look like this::
79
94
80
95
from selenium.webdriver.support.ui import WebDriverWait
@@ -95,6 +110,9 @@ The ``element.py`` will look like this::
95
110
element = driver.find_element_by_name(self.locator)
96
111
return element.get_attribute("value")
97
112
113
+ Locators
114
+ ~~~~~~~~
115
+
98
116
The ``locators.py `` will look like this::
99
117
100
118
from selenium.webdriver.common.by import By
0 commit comments