forked from mate-academy/selenium_form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselenium_basic.py
38 lines (27 loc) · 1.36 KB
/
selenium_basic.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
# https://www.seleniumeasy.com/test/basic-first-form-demo.html
# Add case for Two Input Fields block
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
TEST_DATA = {
'single_input': 'My best message here!!',
'two_input_first': 333,
'two_input_second': 444
}
driver = webdriver.Chrome()
driver.get("https://www.seleniumeasy.com/test/basic-first-form-demo.html")
time.sleep(5)
if driver.find_element(By.ID, "at-cv-lightbox-close").size != 0:
driver.find_element(By.ID, "at-cv-lightbox-close").click()
driver.find_element(By.CSS_SELECTOR, "input#user-message").send_keys(TEST_DATA['single_input'])
driver.find_element(By.CSS_SELECTOR, "form#get-input button").click()
assert driver.find_element(By.ID, "display").text == TEST_DATA['single_input']
time.sleep(5)
driver.find_element(By.CSS_SELECTOR, "#sum1").send_keys(TEST_DATA['two_input_first'])
driver.find_element(By.CSS_SELECTOR, "#sum2").send_keys(TEST_DATA['two_input_second'])
driver.find_element(By.CSS_SELECTOR, "button.btn:nth-child(3)").click()
assert driver.find_element(By.CSS_SELECTOR, "#displayvalue").text == str(TEST_DATA['two_input_first'] + TEST_DATA['two_input_second'])
time.sleep(3)
if driver.find_element(By.CSS_SELECTOR, "#displayvalue").text == str(TEST_DATA['two_input_first'] + TEST_DATA['two_input_second']):
print("Test OK")
driver.quit()