python+自动化培训测试学习笔记
2021/12/3 17:08:35
本文主要是介绍python+自动化培训测试学习笔记,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
from selenium import webdriver from selenium.webdriver.common.by import By driver=webdriver.Chrome() driver.implicitly_wait(10) driver.get("http://www.baidu.com") #id定位 driver.find_element(By.ID,"kw").send_keys("搜索内容") #name定位 driver.find_element(By.NAME,"wd").send_keys("搜索内容") #链接文本定位 driver.find_element(By.LINK_TEXT,"新闻").click() #部分链接文本定位 driver.find_element(By.PARTIALLINK_TEXT,"新").click() #xpath定位 #绝对路径:/开头 full path #相对路径://开头,如ctrl+F搜索//input #1.相对路径+索引定位 driver.find_element(By.XPATH,"//form/span[1]/input").send_keys("搜索内容") #2.相对路径+属性定位//input[@autocomplete='off'] #3.相对路径+通配符定位//*[@*='off'] #4.相对路径+部分属性值定位//*[starts-with(@autocomplete,'of')] //*[contains(@autocomplete,'of')] #5.相对路径+文本定位//span[text()='按图片搜索']
这篇关于python+自动化培训测试学习笔记的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python