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

Skip to content

Commit 9e4d949

Browse files
committed
simplify sentences
1 parent 7e47b00 commit 9e4d949

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

source/page-objects.rst

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
Page Objects
44
------------
55

6-
This chapter is a tutorial introduction to page objects design pattern. A page
7-
object represents an area in the web application user interface that your test
8-
is interacting.
6+
This chapter is a tutorial introduction to the Page Objects design pattern. A
7+
page object represents an area where the test interacts within the web
8+
application user interface.
99

1010
Benefits of using page object pattern:
1111

12-
* Creating reusable code that can be shared across multiple test cases
12+
* Creating reusable code that can share across multiple test cases
1313
* Reducing the amount of duplicated code
1414
* If the user interface changes, the fix needs changes in only one place
1515

1616

1717
Test case
1818
~~~~~~~~~
1919

20-
Here is a test case which searches for a word in python.org website and ensure
21-
some results are found.
20+
Here is a test case that searches for a word on the `python.org` website and
21+
ensures some results. The following section will introduce the `page` module
22+
where the page objects will be defined.
2223

2324
::
2425

@@ -34,11 +35,10 @@ some results are found.
3435
self.driver.get("http://www.python.org")
3536

3637
def test_search_in_python_org(self):
37-
"""
38-
Tests python.org search feature. Searches for the word "pycon" then verified that some results show up.
39-
Note that it does not look for any particular text in search results page. This test verifies that
40-
the results were not empty.
41-
"""
38+
"""Tests python.org search feature. Searches for the word "pycon" then
39+
verified that some results show up. Note that it does not look for
40+
any particular text in search results page. This test verifies that
41+
the results were not empty."""
4242

4343
#Load the main page. In this case the home page of Python.org.
4444
main_page = page.MainPage(self.driver)
@@ -61,9 +61,9 @@ some results are found.
6161
Page object classes
6262
~~~~~~~~~~~~~~~~~~~
6363

64-
The page object pattern intends creating an object for each web page. By
65-
following this technique a layer of separation between the test code and
66-
technical implementation is created.
64+
The page object pattern intends to create an object for each part of a web page.
65+
This technique helps build a separation between the test code and the actual
66+
code that interacts with the web page.
6767

6868
The ``page.py`` will look like this::
6969

@@ -78,7 +78,8 @@ The ``page.py`` will look like this::
7878

7979

8080
class BasePage(object):
81-
"""Base class to initialize the base page that will be called from all pages"""
81+
"""Base class to initialize the base page that will be called from all
82+
pages"""
8283

8384
def __init__(self, driver):
8485
self.driver = driver
@@ -92,10 +93,12 @@ The ``page.py`` will look like this::
9293

9394
def is_title_matches(self):
9495
"""Verifies that the hardcoded text "Python" appears in page title"""
96+
9597
return "Python" in self.driver.title
9698

9799
def click_go_button(self):
98100
"""Triggers the search"""
101+
99102
element = self.driver.find_element(*MainPageLocators.GO_BUTTON)
100103
element.click()
101104

@@ -122,6 +125,7 @@ The ``element.py`` will look like this::
122125

123126
def __set__(self, obj, value):
124127
"""Sets the text to the value supplied"""
128+
125129
driver = obj.driver
126130
WebDriverWait(driver, 100).until(
127131
lambda driver: driver.find_element_by_name(self.locator))
@@ -130,6 +134,7 @@ The ``element.py`` will look like this::
130134

131135
def __get__(self, obj, owner):
132136
"""Gets the text of the specified object"""
137+
133138
driver = obj.driver
134139
WebDriverWait(driver, 100).until(
135140
lambda driver: driver.find_element_by_name(self.locator))
@@ -141,17 +146,20 @@ Locators
141146
~~~~~~~~
142147

143148
One of the practices is to separate the locator strings from the place where
144-
they are being used. In this example, locators of the same page belong to same
145-
class.
149+
they are getting used. In this example, locators of the same page belong to the
150+
same class.
146151

147152
The ``locators.py`` will look like this::
148153

149154
from selenium.webdriver.common.by import By
150155

151156
class MainPageLocators(object):
152157
"""A class for main page locators. All main page locators should come here"""
158+
153159
GO_BUTTON = (By.ID, 'submit')
154160

155161
class SearchResultsPageLocators(object):
156-
"""A class for search results locators. All search results locators should come here"""
162+
"""A class for search results locators. All search results locators should
163+
come here"""
164+
157165
pass

0 commit comments

Comments
 (0)