-
Notifications
You must be signed in to change notification settings - Fork 2
/
WPPost.py
101 lines (85 loc) · 2.97 KB
/
WPPost.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import WPMenu
import WPSidebar
import WPFooter
from selenium.webdriver.common.by import By
# WPPost
# Written by Angela Korra'ti
# Last updated 7/20/2023
#
# This is a helper class to define the layout of a post on the test site.
class WPPost:
driver = None
wp_lib = None
wp_menu = None
wp_sidebar = None
wp_footer = None
def __init__(self, driver, wp_lib):
"""
Init method.
:param driver: Webdriver object
:param wp_lib: wp_lib object for the helper class to get ids, classes, xpaths
"""
self.driver = driver
self.wp_lib = wp_lib
# Initialize the menu object
self.wp_menu = WPMenu.WPMenu(self.driver)
# Initialize the sidebar object
self.wp_sidebar = WPSidebar.WPSidebar(self.driver, self.wp_lib)
# Initialize the footer object
self.wp_footer = WPFooter.WPFooter(self.driver, self.wp_lib)
@property
def site_title_element(self):
"""
:return: The Webdriver element that refers to the site title.
"""
return self.driver.find_element(By.CLASS_NAME, self.wp_lib.site_title['class'])
@property
def site_title(self):
"""
:return: The text of the site title.
"""
site_title_element = self.driver.find_element(By.CLASS_NAME, self.wp_lib.site_title['class'])
return site_title_element.text
@property
def site_description_element(self):
"""
:return: The Webdriver element that refers to the site description.
"""
return self.driver.find_element(By.CLASS_NAME, self.wp_lib.site_description['class'])
@property
def site_description(self):
"""
:return: The text of the site description.
"""
site_description_element = self.driver.find_element(By.CLASS_NAME, self.wp_lib.site_description['class'])
return site_description_element.text
@property
def content_area_element(self):
"""
:return: The Webdriver element that refers to the overall content area.
"""
return self.driver.find_element(By.ID, self.wp_lib.content_id)
@property
def primary_content_area_element(self):
"""
:return: The Webdriver element that refers to the primary content area.
"""
return self.driver.find_element(By.ID, self.wp_lib.primary_content_id)
@property
def secondary_content_area_element(self):
"""
:return: The Webdriver element that refers to the secondary content area.
"""
return self.driver.find_element(By.ID, self.wp_lib.secondary_content_id)
@property
def post_title_element(self):
"""
:return: The Webdriver element that refers to the post title.
"""
return self.driver.find_element(By.CLASS_NAME, self.wp_lib.entry_title_class)
@property
def post_title_text(self):
"""
:return: The text of the post title.
"""
return self.post_title_element.text