-
Notifications
You must be signed in to change notification settings - Fork 0
/
All_logic.py
48 lines (39 loc) · 1.51 KB
/
All_logic.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
import time
from selenium.webdriver.common.keys import Keys
def find_fields_and_button(driver):
forms = driver.find_elements_by_tag_name('form')
# print('count form: ' + str(len(forms)))
for form in forms:
inputs = form.find_elements_by_tag_name('input')
inputs_and_button = []
for i in inputs:
is_displayed = i.is_displayed()
if is_displayed:
inputs_and_button.append(i)
if len(inputs_and_button) == 2:
return inputs_and_button
raise Exception('The elements was not found')
def login(inputs_and_pass, login_word, password):
inputs_and_pass[0].send_keys(login_word)
inputs_and_pass[1].send_keys(password)
inputs_and_pass[1].send_keys(Keys.RETURN)
def special_action(driver, query_num):
if query_num == 1:
button_label = input('Enter a label>>: ')
buttons = driver.find_elements_by_xpath('//*[contains(text(),"' + button_label + '")]')
for button in buttons:
if button.text.upper() == button_label.upper() and button.is_displayed():
button.click()
time.sleep(3)
def find_fields(driver):
forms = driver.find_elements_by_tag_name('form')
# print('count form: ' + str(len(forms)))
for form in forms:
inputs = form.find_elements_by_tag_name('input')
ins = []
for i in inputs:
if i.is_displayed():
ins.append(i)
if len(ins) == 2:
return ins
print('Inputs not found')