selenium Java-1 配置
1.使用intellij新建一个maven项目,名字自定。在pom中写入selenium的依赖。其他依赖也添加到该文件中。
[maven selenium依赖](http://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/3.12.0)
[testNg依赖](http://mvnrepository.com/artifact/org.testng/testng/6.14.3)
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.12.0</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
上述操作后,如果project报错,提示“the type's content type is element-only”,就将该行删除,重新输一次。
2.如果下载过慢,就修改settings。intellij-preferances-maven-usersetting file-settings.xml。通过目录查找settings.xml

<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOF>
</mirror>
3.简单的用例
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class Baidu {
public static void main(String[] args){
//设置Chromedriver的版本
//System.setProperty("webdriver.chrome.driver","路径");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
driver.get("https://www.baidu.com");
driver.findElement(By.xpath("//input[@class='s_ipt' and @id='kw']")).sendKeys("selenium");
driver.findElement(By.xpath("//input[@id='su']")).click();
System.out.println(driver.findElement(By.xpath("//span[@class='nums_text']")).getText());
driver.quit();
}
}

selenium Java-1 配置的更多相关文章
- Selenium Java环境配置
Selenium Java环境配置 上次配置的是C#的环境,今天主要来配置一下Java环境. 首先,对于java环境配置最基础的JDK和JRE 先前我做过配置,这里就不重述了,网上的教程超级多.在基础 ...
- 自动化测试框架selenium+java+TestNG——配置篇
最近来总结下自动化测试 selenium的一些常用框架测试搭配,由简入繁,最简单的就是selenium+java+TestNG了,因为我用的是java,就只是总结下java了. TestNG在线安装: ...
- Selenium+Java+TestNG环境配置
1. JDK 2.eclipse+TestNG >TestNG安装. Name:testng Location:http://beust.com/eclipse.如图: 3.seleniu ...
- selenium第一课(selenium+java+testNG+maven)
selenium介绍和环境搭建 一.简单介绍 1.selenium:Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包 ...
- 行为驱动:Cucumber + Selenium + Java(一) - 环境搭建
1.1 什么是行为驱动测试 说起行为驱动,相信很多人听说过. 行为驱动开发-BDD(Behavior Driven Development)是一个诞生于2003年的软件开发理念.其关键思想在于通过与利 ...
- Selenium Web 自动化 - Selenium(Java)环境搭建
Selenium Web 自动化 - Selenium(Java)环境搭建 2016-07-29 1 下载JDK JDK下载地址:http://www.oracle.com/technetwork/j ...
- 利用Selenium+java实现淘宝自动结算购物车商品(附源代码)
转载请声明原文地址! 本次的主题是利用selenium+java实现结算购买购物车中的商品. 话不多说,本次首先要注意的是谷歌浏览器的版本,浏览器使用的驱动版本,selenium的jar包版本. ...
- Selenium+Java(二)Selenium打开IE浏览器
前言 已在Eclipse中配置完成Selenium的相关配置,不知道如何配置的可参考我的另一篇博文:https://www.cnblogs.com/yogouo/p/11946940.html 打开I ...
- web端自动化——Selenium Server环境配置
Selenium Server环境配置 下面下载.配置并运行Selenium Server. ① 下载 Selenium Server. 下载地址为:https://pypi.python.or ...
- selenium+java+testNG+maven环境搭建
一.简单介绍 1.selenium: Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包括IE.Mozilla Fir ...
随机推荐
- Spring学习笔记之The IoC container
IoC is also known as dependency injection (DI). 这是一个过程?什么样的过程呢?对象自己定义它的依赖关系,这意味着,那些他们依赖的对象,只能通过构造函数参 ...
- 利用InstallShiled 10.5制作AE应用程序安装包
[转]利用InstallShiled 10.5制作AE应用程序安装包 作者:3SNEWS 社区ESRI(ArcGIS)版版主:zhaoxiang_whuhttp://www.3snews.net/bb ...
- Osmocom-bb系统编译
Ubuntu 12.04.5 LTS i386环境下编译 sudu su --------------------------------------------------------------- ...
- ubuntu16 intellij idea install lombok plugin
项目中用到lombok,idea会出现类似编译报错的红色,但并不影响运行.所以为了没有类似警告,就在idea上安装lombok插件.file-settings 安装完成之后,按照提示重启idea,问题 ...
- python3:jsonpath-rw处理Json对象
前提:接口自动化测试中,存在依赖情况:test_02的某个请求参数的值,需要依赖test_01返回结果中某个字段的数据,所以就先需要拿到返回数据中特定字段的值.这里使用到python中jsonpath ...
- I.MX6 HUAWEI MU609 3G porting
/*************************************************************************** * I.MX6 HUAWEI MU609 3G ...
- 【error】Invalid ADAPTORNAME specified. Type 'imaqhwinfo' for a list of available ADAPTORNAMEs.
前言 使用matlab通过摄像头获取图像进行处理: 问题描述 使用matalb调用摄像头时出现错误: >> imaqhwinfo Warning: No Image Acquisition ...
- jenkins构建配置
# Poll SCM:定时检查源码变更(根据SCM软件的版本号),如果有更新就checkout最新code下来,然后执行构建动作 # 每5分钟检查一次源码变化 # Build periodically ...
- 第三周作业3——Bug Report
作业要求来自:https://edu.cnblogs.com/campus/nenu/SWE2017FALL/homework/957 要求1: 准备工作:利用老师提供的git 命令,批量pull所有 ...
- hdu2090-2097
hdu2090 模拟 #include<stdio.h> int main(){ ]; ,a1,a2; ; while(scanf("%s%lf%lf",b,& ...