摘要: switch_to.frame() 切换frame switch_to.default_content() 切换到主页面 #从frame中切回主文档 switch_to.parent_frame() 这是switch_to中独有的方法,可以切换到上一层的frame,对于层层嵌套的frame很有用 # 阅读全文
posted @ 2019-12-14 20:37 小白龙白龙马 阅读(496) 评论(0) 推荐(0)
摘要: options = driver.find_elements_by_tag_name('option') #获取所有的option子元素 options[2].click() #获取第三个元素 for i in range(len(options)): #选择value值为python的子项 if 阅读全文
posted @ 2019-12-14 03:37 小白龙白龙马 阅读(631) 评论(0) 推荐(0)
摘要: 参考官方文档:https://selenium.dev/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.select.html?highlight=all_selected_options#selenium.webd 阅读全文
posted @ 2019-12-14 01:52 小白龙白龙马 阅读(3324) 评论(0) 推荐(0)
摘要: 对于链接对象常见的操作有:单击、获取链接文字、获取链接地址等: from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox() # 指定和打开浏览器url1='http://www.baidu.com' 阅读全文
posted @ 2019-12-13 19:25 小白龙白龙马 阅读(818) 评论(0) 推荐(0)
摘要: webelement对象操作 webelement对象是selenium中所有元素的父类,也就是webelement对象拥有的方法,其它元素对象都会有; 只是不同的对象在调用特定方法时,效果是不一样的,即: 某些方法只是针对特定元素类型有效,而对其它类型无效。 (1)、clear:清空文本框中的文本 阅读全文
posted @ 2019-12-13 18:55 小白龙白龙马 阅读(5373) 评论(0) 推荐(0)
摘要: 文本框对象 from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox() # 指定和打开浏览器url1='http://www.baidu.com'driver.get(url1) #打开第一个网址 阅读全文
posted @ 2019-12-13 17:02 小白龙白龙马 阅读(622) 评论(0) 推荐(0)
摘要: d 阅读全文
posted @ 2019-12-13 16:34 小白龙白龙马 阅读(905) 评论(0) 推荐(0)
摘要: 定位元素,selenium提供了8中元素定位方法: (1)find_element_by_id() :html规定,id在html中必须是唯一的,有点类似于身份证号 (2)find_element_by_name() :html规定,name用来指定元素的名称,有点类似于人名 (3)find_ele 阅读全文
posted @ 2019-12-13 02:17 小白龙白龙马 阅读(2150) 评论(0) 推荐(0)
摘要: 参考文档:https://www.runoob.com/cssref/css-selectors.html CSS选择器用于选择你想要的元素的样式的模式。 "CSS"列表示在CSS版本的属性定义(CSS1,CSS2,或对CSS3)。 选择器示例示例说明CSS .class .intro 选择所有cl 阅读全文
posted @ 2019-12-13 00:27 小白龙白龙马 阅读(339) 评论(0) 推荐(0)
摘要: 参考文档:https://www.w3school.com.cn/cssref/css_selectors.asp 选择器例子例子描述CSS .class .intro 选择 class="intro" 的所有元素。 1 #id #firstname 选择 id="firstname" 的所有元素。 阅读全文
posted @ 2019-12-13 00:22 小白龙白龙马 阅读(202) 评论(0) 推荐(0)