【selenium---浏览器操作方法】教程文章相关的互联网学习教程文章

Maven 手动添加selenium JAR 包到本地仓库【图】

在intellij中创建maven项目时,添加 selenium 依赖包时下载不到远程依赖包报错,需要手动添加jar包到本地仓库推荐几个好的 Maven 常用仓库网址:http://mvnrepository.com/http://search.maven.org/http://repository.sonatype.org/content/groups/public/http://people.apache.org/repo/m2-snapshot-repository/http://people.apache.org/repo/m2-incubating-repository/ 手动安装时不需要改变这些信息。Maven 安装 JAR 包的命令...

selenium对iframe操作小结【代码】

selenium获取iframe中内容selenium提供了三种方法来获取iframe中的内容:语法:driver.switch_to_frame()或driver.switch_to.frame() ①iframe有id,传入id获取②iframe有name,传入name获取③通过tag_name获取所有的iframe,选择我们要进入的iframe,代码:#用于页面中有多个iframe并列 #假如我们要进入的是第一个iframe, driver.switch_to_frame( driver.find_elements_by_tag_name(‘iframe‘)[0])当页面中iframe中还有iframe时...

selenium借助AutoIt识别上传(下载)详解【代码】【图】

AutoIt目前最新是v3版本,这是一个使用类似BASIC脚本语言的免费软件,它设计用于Windows GUI(图形用户界面)中进行自动化操作。它利用模拟键盘按键,鼠标移动和窗口/控件的组合来实现自动化任务。 官方网站:https://www.autoitscript.com/site/ 从网站上下载AutoIt并安装,安装完成在菜单中会看到图4.13的目录: 图4.13 AutoIt菜单AutoIt Windows Info 用于帮助我们识Windows控件信息。Compi...

selenium WebDriver:使用TestNG进行数据驱动

如下为结合testNG进行的数据驱动测试package cn.gloryroad;import org.testng.annotations.Test;import org.testng.annotations.DataProvider;import org.testng.annotations.Test;import org.testng.annotations.BeforeMethod;import org.testng.annotations.AfterMethod;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebDriver.Navigation;import org.openqa.selenium.ie.In...

selenium判断元素类型【代码】【图】

在做级联的下拉框时发现第一次选择了下拉框(如省份),第二个下拉框可能是输入框,也可能是下拉框,这个时候就需要判断他的元素类型,来做判断图1图2原理很简单:获取控件的html文件内容,拿到内容后在做判断图1的html元素为:<input type="text" name="province" class="choiceCountry inputText long js_choiceState" value="">图2的html元素为:做法:WebElement elem = driver.findElement(By.cssSelector("#addressfrom > ul...

selenium自动化之鼠标操作(转)【图】

在做自动化测试的时候,经常会遇到这种情况,某个页面元素,你必须要把鼠标移动到上面才能显示出元素。那么这种情况,我们怎么处理呢?,selenium给我们提供了一个类来处理这类事件——ActionChains。ActionChains可以对需要模拟鼠标操作才能进行的情况,比如单击、双击、点击鼠标右键、拖拽等等进行操作。ActionChains方法列表:click(on_element=None) ——单击鼠标左键click_and_hold(on_element=None) ——点击鼠标左键,不松开...

Selenium脚本之基本元素常用方法

页面基本元素:1.图片上传方法 private static void fileUpload(WebDriver driver, String s, String filepath) { WebElement file = driver.findElement(By.name(s)); file.sendKeys(filepath); }调用: fileUpload(driver, "file", "C:\\pictures\\pic1.jpg");原文:http://blog.51cto.com/hongz/2053880

phantomjs和selenium设置proxy、headers【代码】

设置ip方法1:service_args = [‘--proxy=%s‘ % ip_html, # 代理 IP:prot (eg:192.168.0.28:808)‘--proxy-type=http’, # 代理类型:http/https‘--load-images=no’, # 关闭图片加载(可选)‘--disk-cache=yes’, # 开启缓存(可选)‘--ignore-ssl-errors=true’ # 忽略https错误(可选)] driver = webdriver.PhantomJS(service_args=service_args) 方法2:browser=webdriver....

【转】selenium自动化测试用例需要关注的几点(一)

自动化测试设计简介 注:参看文章地址  我们在本章提供的信息,对自动化测试领域的新人和经验丰富的老手都是有用的。本篇中描述最常见的自动化测试类型, 还描述了可以增强您的自动化测试套件可维护性和扩展性的“设计模式”。还没有使用这些技术的、有经验的自动化测试工程师会对这些技术更加感兴趣。  测试类型  您应该测试应用程序中的哪些部分?这取决于您的项目的各种影响因素:用户的期望,时间期限,项目经理设置的优...

使用selenium时,如何通过cookie来模拟登陆?【代码】

现在许多网站的登陆都会比较复杂,有时直接使用Cookie模拟登陆不失为一个简单粗暴的方法。 使用Cookie来模拟登陆,就是用户在浏览器先登录网站,然后将Cookie信息拷贝出来,用来设置请求的Cookie。 以模拟登陆知乎为例:from selenium import webdriver from selenium.webdriver import Chrome,ChromeOptionsoptions = ChromeOptions() options.add_argument(user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537...

Selenium3自动化测试【16】元素定位之Tag【代码】【图】

tag name方法是通过对HTML页面中tag name匹配方式来定位元素的。类似与JavaScript中的getElementsByTagName()。tag name方法在某些特定场合下十分有用,例如,通过标签<checkbox>的tag name可以一次性定位到页面中的所有复选框元素。 1. 通过tag name定位Bing案例 依旧使用Bing首页的搜索框为例。例:find_element_by_tag_name("input").send_keys("1234")。搜索框元素的属性描述HTML代码如下,可以观察到该元素的标签是<input>:...

Selenium Firefox 官方Webdriver -- Geckodriver【图】

下载地址:https://github.com/mozilla/geckodriver/releases配置环境:直接将解压的geckodriver.exe放到python的Scripts中比如:我的路径 原文:https://www.cnblogs.com/whu-2017/p/9206323.html

win7-64 位操作系统下,联网安装selenium【代码】

下载官网 https://pip.pypa.io/en/latest/installing.html官网截图如下:pip included with Python?Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default [1], so you may have pip already.Install pip?To install pip, securely download get-pip.py. [2]Then run the following (which may require administrator access):python get-pip.py 安装selenium,联网状态的话,可以直...

selenium爬取豆瓣电影 保存CSV格式【代码】

selenium爬取豆瓣电影 保存CSV格式 from selenium import webdriver import csv from multiprocessing import Poolfp = open("电影.csv",'a') write = csv.writer(fp) write.writerow(['电影名称','评分','评论人数','代表名言','电影信息']) brower = webdriver.Chrome('C:\Program Files\Google\Chrome\Application\Chromedriver.exe') def get(URL):try:brower.get(URL)title = brower.find_elements_by_css_selector('div.hd')...

selenium RC 环境配置【代码】

selenium RC 环境配置2011-10-19 12:58 by 虫师, 37117 阅读, 12 评论, 收藏, 编辑 在网上搜索了许久,没找到有具体的配置,只是简单了写了几个步骤,自己琢磨了一下,于是,就想整理一篇文章,便于以后温习。本文是参照官网的步骤进行了,当然了,也不完成相同。在这里我要说的是java的环境,如查你是使用的其它语言,请参考其它文章。下面我们通过eclipse 来搭建自己的环境。http://seleniumhq.org/docs/appendix_installing_j...