-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.py
30 lines (20 loc) · 885 Bytes
/
base.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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Base:
def __init__(self, url) -> None:
self.options = Options()
self.options.add_argument('--start-maximized')
self.driver = webdriver.Chrome(options=self.options)
self.url = url
def get_page(self):
self.driver.get(self.url)
def get_element(self, value):
return self.driver.find_element(By.XPATH, value)
def click_on_element(self, value):
self.driver.execute_script("arguments[0].click();", WebDriverWait(self.driver, 20).until(
EC.element_to_be_clickable((By.XPATH, value))))
def close_context(self):
self.driver.close()