-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal.py
81 lines (56 loc) · 1.8 KB
/
local.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#coding = utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time,os
brower = webdriver.Chrome()
# brower.maximize_window()
file_path = 'file:///' + os.path.abspath('test.html')
brower.get(file_path)
brower.implicitly_wait(10)
print("测试checkbox")
inputs = brower.find_elements_by_tag_name('input')
for i in inputs:
if i.get_attribute('type') == 'checkbox':
i.click()
time.sleep(0.5)
brower.find_elements_by_css_selector('input[type=checkbox]').pop().click()
print("测试alter窗口")
brower.find_element_by_name('alterbutton').click()
# time.sleep(1)
brower.switch_to_alert().accept()
# time.sleep(1)
print("测试文件上传")
brower.find_element_by_name('attach[]').send_keys('D:\OneDrive\autotest\local.py')
# time.sleep(1)
print("测试prompt窗口")
brower.find_element_by_name('promptbutton').click()
# time.sleep(1)
s_alert = brower.switch_to_alert()
s_alert.send_keys('hello, world')
# time.sleep(1)
s_alert.accept()
# time.sleep(1)
s_alert.accept()
print("测试confirm窗口")
brower.find_element_by_name('confirmbutton').click()
# time.sleep(1)
s_alert.accept()
# time.sleep(1)
s_alert.accept()
print("测试下拉窗口")
s1 = brower.find_element_by_id('Selector')
s1.find_element_by_xpath("//option[@value='banana']").click()
brower.find_element_by_id('showSelectResult').click()
# time.sleep(1)
s_alert.accept()
print("测试文本框")
brower.find_element_by_id('edit').send_keys('测试文本框')
brower.find_element_by_name('submit').click()
# time.sleep(1)
s_alert.accept()
print("测试radiobox")
ra = brower.find_element_by_id('radio')
ra.find_element_by_xpath("//input[@class='Baidu']").click()
ra1 = ra.find_elements_by_xpath("//label")
for i in ra1:
print(i.text)