昆仑山:眼中无形心中有穴之穴人合一

夫君子之行,静以修身,俭以养德;非澹泊无以明志,非宁静无以致远。夫学须静也,才须学也;非学无以广才,非志无以成学。怠慢则不能励精,险躁则不能冶性。年与时驰,意与岁去,遂成枯落,多不接世。悲守穷庐,将复何及!

 

Web自动化测试(Selenium工具 注意浏览器版本和驱动版本要一致)

环境部署

 pip3 install selenium

安装chrome-browser

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm --no-check-certificate  
sudo yum install google-chrome-stable_current_x86_64.rpm

安装chromedriver:一个用来和chrome交互的接口

sudo yum install chromedriver

浏览器

谷歌浏览器

http://chromedriver.storage.googleapis.com/index.html?path=2.37/

import time

from selenium import webdriver

chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome(chromedriver)
driver.get("http://www.baidu.com")
time.sleep(3)
driver.find_element_by_id("kw").send_keys("selenium软件自动化测试开发")
time.sleep(3)
driver.find_element_by_id("su").click()
time.sleep(3)
driver.quit()
print("Done!")
time.sleep(3)


火狐浏览器

https://github.com/mozilla/geckodriver/releases

import time

from selenium import webdriver

browser = webdriver.Firefox()
browser.get("http://www.baidu.com")
time.sleep(3)
browser.find_element_by_id("kw").send_keys("魔都大上海")
time.sleep(3)
browser.find_element_by_id("su").click()
time.sleep(3)
browser.quit()
time.sleep(3)


posted on 2019-03-01 13:58  Indian_Mysore  阅读(858)  评论(2编辑  收藏  举报

导航