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 配置的更多相关文章

  1. Selenium Java环境配置

    Selenium Java环境配置 上次配置的是C#的环境,今天主要来配置一下Java环境. 首先,对于java环境配置最基础的JDK和JRE 先前我做过配置,这里就不重述了,网上的教程超级多.在基础 ...

  2. 自动化测试框架selenium+java+TestNG——配置篇

    最近来总结下自动化测试 selenium的一些常用框架测试搭配,由简入繁,最简单的就是selenium+java+TestNG了,因为我用的是java,就只是总结下java了. TestNG在线安装: ...

  3. Selenium+Java+TestNG环境配置

    1. JDK 2.eclipse+TestNG >TestNG安装.   Name:testng  Location:http://beust.com/eclipse.如图: 3.seleniu ...

  4. selenium第一课(selenium+java+testNG+maven)

    selenium介绍和环境搭建 一.简单介绍 1.selenium:Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包 ...

  5. 行为驱动:Cucumber + Selenium + Java(一) - 环境搭建

    1.1 什么是行为驱动测试 说起行为驱动,相信很多人听说过. 行为驱动开发-BDD(Behavior Driven Development)是一个诞生于2003年的软件开发理念.其关键思想在于通过与利 ...

  6. Selenium Web 自动化 - Selenium(Java)环境搭建

    Selenium Web 自动化 - Selenium(Java)环境搭建 2016-07-29 1 下载JDK JDK下载地址:http://www.oracle.com/technetwork/j ...

  7. 利用Selenium+java实现淘宝自动结算购物车商品(附源代码)

    转载请声明原文地址! 本次的主题是利用selenium+java实现结算购买购物车中的商品. 话不多说,本次首先要注意的是谷歌浏览器的版本,浏览器使用的驱动版本,selenium的jar包版本.   ...

  8. Selenium+Java(二)Selenium打开IE浏览器

    前言 已在Eclipse中配置完成Selenium的相关配置,不知道如何配置的可参考我的另一篇博文:https://www.cnblogs.com/yogouo/p/11946940.html 打开I ...

  9. web端自动化——Selenium Server环境配置

    Selenium Server环境配置 下面下载.配置并运行Selenium Server. ①    下载 Selenium Server. 下载地址为:https://pypi.python.or ...

  10. selenium+java+testNG+maven环境搭建

    一.简单介绍 1.selenium: Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包括IE.Mozilla Fir ...

随机推荐

  1. 第三视角团队:"Jarvis For Chat"团队选题报告

    "Jarvis For Chat"团队选题报告 组长博客链接 本次作业链接 NABCD在项目中的使用 N(Need,需求) QQ和微信已经成为人们社交的必需品,在QQ有7.8亿活跃 ...

  2. ExceptionHandler 异常公共处理

    异常的公共处理很多种,采用注解的方式,拦截器的方式等都可以,我采用的是继承 AbstractHandlerExceptionResolver 来实现, 上代码 package com.yun.util ...

  3. 深入理解Linux网络技术内幕——PCI层和网络接口卡

    概述     内核的PCI子系统(即PCI层)提供了不同设备一些通用的功能,以便简化各种设备驱动程序.     PCI层重要结构体如下: pci_device_id     设备标识,根据PCI标志定 ...

  4. promise的生命周期

    每个promise都会经历一个短暂的生命周期: 先是处于进行中(pending)状态,此时操作并未完成,所以他也是未处理的(unsettled): 一旦异步惭怍执行结束,promise则 变为已处理( ...

  5. Linux运维常用150个命令

    Linux运维常用150个命令 转载自:www.cnblogs.com/bananaaa/p/7774467.html 命令 功能说明 线上查询及帮助命令(2个) man 查看命令帮助,命令的词典,更 ...

  6. CSS的使用

    1.行内样式/内联样式 特点:在具体的HTML标签中引入CSS代码 语法:所有的HTML标签都具有一个style属性,属性值就可以使用CSS样式规则 <标签 style="CSS样式规 ...

  7. 猎豹免费WiFi-随身WiFi共享热点,永久免费的无线路由器 - imsoft.cnblogs

  8. POJ 2441 Arrange the Bulls 状态压缩递推简单题 (状态压缩DP)

    推荐网址,下面是别人的解题报告: http://www.cnblogs.com/chasetheexcellence/archive/2012/04/16/poj2441.html 里面有状态压缩论文 ...

  9. Ubuntu Linux下的Wireshark使用drcom_2011.lua分析drcom协议

    用文本编辑器打开init.lua配置文件,位置一般是//usr/share/wireshark/init.lua: sudo vim /usr/share/wireshark/init.lua 在in ...

  10. 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 auto-focus

    转载至:https://blog.csdn.net/wo541075754/article/details/75349556 auto-focus 在agenda-group章节,我们知道想要让Age ...