首页 > 其他 > 详细

selenium随笔

时间:2019-06-07 00:52:05      阅读:129      评论:0      收藏:0      [点我收藏+]

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随笔

原文:https://www.cnblogs.com/sasa-python/p/10987373.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!