随笔分类 - python+selenium(webUI自动化)
摘要:转载:https://www.cnblogs.com/poloyy/p/12587729.html 如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识,
阅读全文
posted @ 2020-03-30 14:53
小白龙白龙马
摘要:在实际使用selenium或者appium时,等待下个等待定位的元素出现,特别是web端加载的过程,都需要用到等待,而等待方式的设置是保证脚本稳定有效运行的一个非常重要的手段,在selenium中(appium通用)常用的等待分为: 显示等待WebDriverWait()、隐式等待implicitl
阅读全文
posted @ 2019-12-23 23:38
小白龙白龙马
摘要:有些浏览器的页面操作,不能依靠WebDriver提供的API来操作,需要借助JavaScript脚本。webdriver提供了execute_script()方法来执行JavaScript代码。from selenium import webdriver import time driver = w
阅读全文
posted @ 2019-12-22 23:18
小白龙白龙马
摘要:from selenium import webdriver import time options = webdriver.ChromeOptions() prefs = { 'profile.default_content_settings.popups':0 ,'download.defaul
阅读全文
posted @ 2019-12-22 22:42
小白龙白龙马
摘要:修改Firefox的相关配置。 1、profile.set_preference('browser.download.folderList',2) 设置成0代表桌面,1代表下载到浏览器默认下载路径;2代表保存到自定义目录.设置为2的时候,设置自定义路径的就要去掉。 2、profile.set_pre
阅读全文
posted @ 2019-12-21 20:40
小白龙白龙马
摘要:我们要区分出上传按钮的种类,大体上可以分为两种: 第一种普通上传:将本地文件路径作为一个值,放在input标签中,通过form表单将这个值提交给服务器; 第二种插件上传:是通过Flash、JavaScript、Ajax等实现(标签非input)的上传功能; 对于通过input标签实现的上传功能,可以
阅读全文
posted @ 2019-12-21 17:03
小白龙白龙马
摘要:from selenium.webdriver.common.action_chains import ActionChains #导入鼠标相关的包 submit = driver.find_element_by_id('kw') #首先创建对象 ActionChains(driver).click
阅读全文
posted @ 2019-12-15 02:07
小白龙白龙马
摘要:from selenium.webdriver.common.keys import Keys #键盘导入类 常用的键盘操作: send_keys(Keys.BACK_SPACE):删除键(BackSpace) send_keys(Keys.SPACE):空格键(Space) send_keys(K
阅读全文
posted @ 2019-12-15 01:39
小白龙白龙马
摘要:首先使用switch_to.alert()方法进行定位,然后可以使用下面的操作text:返回alert、confirm、prompt中的文字信息;accept():接受现有警告框;dismiss():解散现有警告框;send_keys():在警告框中输入文本(如果可以输入的话); from sele
阅读全文
posted @ 2019-12-14 21:33
小白龙白龙马
摘要:alt.accept() : 等同于单击“确认”或者“OK” alt.dismiss() : 等同于单击“取消”或者“Cancel” alt.send_keys() : 发送文本,针对有提交需求的prompt框 alt.text() : 获取alert文本的内容 alt.authenticate(u
阅读全文
posted @ 2019-12-14 21:04
小白龙白龙马
摘要:switch_to.frame() 切换frame switch_to.default_content() 切换到主页面 #从frame中切回主文档 switch_to.parent_frame() 这是switch_to中独有的方法,可以切换到上一层的frame,对于层层嵌套的frame很有用 #
阅读全文
posted @ 2019-12-14 20:37
小白龙白龙马
摘要: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
小白龙白龙马
摘要:参考官方文档: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
小白龙白龙马
摘要:对于链接对象常见的操作有:单击、获取链接文字、获取链接地址等: from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox() # 指定和打开浏览器url1='http://www.baidu.com'
阅读全文
posted @ 2019-12-13 19:25
小白龙白龙马
摘要:webelement对象操作 webelement对象是selenium中所有元素的父类,也就是webelement对象拥有的方法,其它元素对象都会有; 只是不同的对象在调用特定方法时,效果是不一样的,即: 某些方法只是针对特定元素类型有效,而对其它类型无效。 (1)、clear:清空文本框中的文本
阅读全文
posted @ 2019-12-13 18:55
小白龙白龙马
摘要:文本框对象 from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox() # 指定和打开浏览器url1='http://www.baidu.com'driver.get(url1) #打开第一个网址
阅读全文
posted @ 2019-12-13 17:02
小白龙白龙马
摘要:定位元素,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
小白龙白龙马
摘要:参考文档:https://www.runoob.com/cssref/css-selectors.html CSS选择器用于选择你想要的元素的样式的模式。 "CSS"列表示在CSS版本的属性定义(CSS1,CSS2,或对CSS3)。 选择器示例示例说明CSS .class .intro 选择所有cl
阅读全文
posted @ 2019-12-13 00:27
小白龙白龙马
摘要:参考文档: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
小白龙白龙马

浙公网安备 33010602011771号