1、使用selenium中的webdriver模块对浏览器进行 *** 作
1)b = webdriver.firefox() #打开浏览器
2)b.get(‘http://www.baIDu.com‘) #打开一个网页
判断url,Title找到元素方式
3)b.Title,current_url 判断访问是否有效
4) ele = find_element_by_ID/name() #定位元素
5)ele.clear() ele.send_keys() 清空和输入
6)b.back() #back
2、webdriver模块对浏览器进行 *** 作:元素的定位
7)ele = find_element_by_link_text(‘企业直通班’)
8)ele = find_element_by_partial_link_text(‘直通班’)
9)ele = find_element_by_CSS_selector(‘input[ID=\‘search\‘]‘)
ele = find_element_by_CSS_selector(‘img[alt="麦子学院三周年"]’)
10)xpath定位文件:/ // . .. @ID count
ele = find_element_by_xpath(‘//input‘)
ele = find_element_by_xpath(‘//input[0]‘)
ele = find_element_by_xpath(‘//form//input[0]‘)
ele = find_element_by_xpath(‘//form//input/..‘)
find_element_by_xpath(‘//input[@ID]‘)
find_element_by_xpath(‘//input[@name="firstname"]‘)
find_element_by_xpath(‘//*[count(input)=2]‘)
总结以上是内存溢出为你收集整理的selenium随笔全部内容,希望文章能够帮你解决selenium随笔所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)