-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselenium_methods.py
30 lines (22 loc) · 928 Bytes
/
selenium_methods.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
import allure
from allure_commons.types import AttachmentType
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
TIMEOUT = 30
DELIMITER = ','
def main(driver, ec, config):
locator_type, locator = config.split(DELIMITER)
locator_type = eval('By.' + locator_type)
element = WebDriverWait(driver, TIMEOUT).until(ec((locator_type, locator)))
allure.attach(driver.get_screenshot_as_png(), name='Screenshot', attachment_type=AttachmentType.PNG)
return element
def find_element(driver, config):
element = main(driver, EC.presence_of_element_located, config)
return element
def enter_text(driver, config, text):
element = find_element(driver, config)
element.clear()
element.send_keys(text)
element.send_keys(Keys.RETURN)