-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_element.py
More file actions
26 lines (21 loc) · 877 Bytes
/
base_element.py
File metadata and controls
26 lines (21 loc) · 877 Bytes
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
"""
Elements
"""
from selenium.webdriver.support.ui import WebDriverWait
class BasePageElement:
"""Base page class that is initialized on every page object class."""
locator = None
def __set__(self, obj, value):
"""Sets the text to the value supplied"""
driver = obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element_by_name(self.locator))
driver.find_element_by_name(self.locator).clear()
driver.find_element_by_name(self.locator).send_keys(value)
def __get__(self, obj, owner):
"""Gets the text of the specified object"""
driver = obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element_by_name(self.locator))
element = driver.find_element_by_name(self.locator)
return element.get_attribute("value")