1 from selenium import webdriver
2 from selenium.webdriver.common.action_chains import ActionChains
3 import time
4 import random
5 import base64
6
7 from selenium.webdriver.common.keys import Keys
8
9 driver = webdriver.Chrome()
10
11 def Login():
12 # 打开网站
13 driver.get("http://litemall.hogwarts.ceshiren.com/vue/index.html#/login?redirect=user")
14 time.sleep(1)
15 # 填充用户名
16 driver.find_element_by_css_selector("#app > div.login.view-router > div.field_group > div:nth-child(1) > div.md_field_control > input[type=text]").send_keys("reliable")
17 time.sleep(1)
18 # 填充密码
19 driver.find_element_by_css_selector("#app > div.login.view-router > div.field_group > div:nth-child(2) > div.md_field_control > input[type=password]").send_keys("success01")
20 # 点击登录
21 driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/button').click()
22 time.sleep(1)
23 driver.find_element_by_css_selector("#app > div.van-hairline--top-bottom.van-tabbar.van-tabbar--fixed > div:nth-child(1) > div.van-tabbar-item__icon > i").click()
24 time.sleep(1)
25 driver.find_element_by_class_name('van-field__control').click()
26 time.sleep(1)
27 driver.find_element_by_class_name('van-field__control').send_keys("火焰杯测试商品")
28 time.sleep(1)
29 driver.find_element_by_class_name('van-field__control').send_keys(Keys.ENTER)
30 time.sleep(1)
31 #加入购物车 //*[@id="app"]/div[2]/div[2]/div[1]/div/div/div[1]/div
32
33 driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[2]/div[1]/div/div/div[1]/div').click()
34 time.sleep(1)
35 driver.find_element_by_xpath('// *[ @ id = "app"] / div[2] / div[5] / button[1]').click()
36 time.sleep(2)
37 driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[3]/div[3]/div[3]/button[1]').click()
38 time.sleep(2)
39 driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[5]/div[1]/div').click()
40
41 if __name__ == "__main__":
42 Login()
【软件测试】“火焰杯”自动化测试第一题
最新推荐文章于 2024-09-09 00:00:00 发布