-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_element.py
56 lines (48 loc) · 2.18 KB
/
test_element.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
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
class BasePageElement(object):
def __set__(self, obj, value):
driver =obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_element(By.NAME, self.locator))
driver.find_element(by=By.NAME,value =self.locator).clear()
time.sleep(2)
driver.find_element(by=By.NAME,value =self.locator).send_keys(value)
time.sleep(2)
def __get__(self, obj,owner):
driver = obj.driver
WebDriverWait(driver,100).until(
lambda driver: driver.find_element(by=By.NAME,value =self.locator))
element=driver.find_element(by=By.NAME,value =self.locator)
return element.get_attribute("value")
class CookiePageElement(object):
def __set__(self, obj, value):
driver =obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_elements(By.ID, self.locator))
time.sleep(5)
def __get__(self, obj,owner):
driver = obj.driver
WebDriverWait(driver,100).until(
lambda driver: driver.find_element(by=By.ID,value =self.locator))
element=driver.find_element(by=By.ID,value =self.locator)
return element.get_attribute("value")
class SearchBarElement(object):
def __set__(self, obj, value):
driver =obj.driver
WebDriverWait(driver, 100).until(
lambda driver: driver.find_elements(By.NAME, value= self.locator))[1]
time.sleep(2)
driver.find_elements(by=By.NAME, value =self.locator)[1].clear()
time.sleep(2)
driver.find_elements(by=By.NAME,value =self.locator)[1].send_keys(value)
driver.find_elements(by=By.NAME,value =self.locator)[1].send_keys(Keys.RETURN)
time.sleep(2)
def __get__(self, obj,owner):
driver = obj.driver
WebDriverWait(driver,100).until(
lambda driver: driver.find_elements(by=By.NAME,value =self.locator))[1]
element=driver.find_elements(by=By.NAME,value =self.locator)[1]
return element.get_attribute("value")