-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlazy_selenium.py
39 lines (30 loc) · 1.06 KB
/
lazy_selenium.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
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
class LazyWebDriver:
__isinstance = False
def __new__(cls, *args, **kwargs):
cls.__isinstance = super().__new__(cls) if not cls.__isinstance else cls.__isinstance
return cls.__isinstance
def __init__(self, driver):
self.driver = driver
def press_enter(self):
ActionChains(self.driver) \
.send_keys(Keys.ENTER) \
.perform()
def click_and_hold(self, element):
ActionChains(self.driver) \
.click_and_hold(element) \
.perform()
def click_and_release(self, element):
ActionChains(self.driver) \
.click(element) \
.perform()
def context_click(self, element):
ActionChains(self.driver) \
.context_click(element) \
.perform()
def click_and_clear_text(self, element):
element.click()
ActionChains(self.driver) \
.send_keys(Keys.CONTROL + "A" + Keys.BACKSPACE) \
.perform()