pythonwebui自动化_python+selenium实现web端UI自动化测试
代碼示例:css
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# coding:utf8
import sys
import os
from selenium import webdriver
sys.path.append(os.getcwd())
driver = webdriver.Chrome('/Users/fyh/tool/chromedriver') # Optional argument, if not specified will search path.
#注意此處的chromedriver須要與瀏覽器的版本匹配,不然會(huì)報(bào)錯(cuò)
# options=webdriver.ChromeOptions()
# options.add_argument('disable-infobars')
driver.set_page_load_timeout(30)
driver.implicitly_wait(30)
#登陸
driver.get("https://h5.daily.weidian.com/m/zhaoshang-h5/apply.html?id=30898")#打開連接
driver.find_element_by_id("J_phone").send_keys("13876543566")#找到控件并發(fā)送文字
driver.find_element_by_id("J_password").send_keys("123456")
driver.find_element_by_id("J_submit").click()#找到控件并點(diǎn)擊按鈕
driver.find_elements_by_class_name("common_button")[0].click()#經(jīng)過find_elements_by_class_name找控件
text=driver.find_element_by_xpath("//*[@id=\"app\"]/div/div/div/section[1]/div[1]/span").text#經(jīng)過find_element_by_xpath找控件
if text == "未經(jīng)過":
print("經(jīng)過")
else:
print("不經(jīng)過")
sleep(2)
driver.quit()
其余方法:html
find_element_by_name()
find_element_by_css_selector()
總結(jié)
以上是生活随笔為你收集整理的pythonwebui自动化_python+selenium实现web端UI自动化测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql out 注意_总结关于in和
- 下一篇: java 百度贴吧 爬虫_JAVA爬虫入