zoukankan      html  css  js  c++  java
  • 自动化测试selenium+java 环境搭建

    1.开发环境:

    a:安装jdk,配置java的环境变量

    b:安装eclipse 工具、火狐浏览器(低版本)

    2.下载selenium包

    selenium-java-2.44.0.jar

    selenium-server-standalone-2.45.0.jar

    selenium-java-2.44.0-srcs.jar

    3.打开eclipse ,将selenium包导入

    4.再编写代码

    import java.sql.Time;
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.server.browserlaunchers.Sleeper;


    public class webdriverdemo {

    public static void main(String[] args) {

      System.setProperty("webdriver.firefox.bin", "D:\Program Files (x86)\Mozilla Firefox\firefox.exe");
      WebDriver driver = new FirefoxDriver();
      driver.get("https://www.baidu.com");

      WebElement text = driver.findElement(By.name("mobile"));
      text.sendKeys("百度");
      Sleeper.sleepTightInSeconds(1);
      text.submit();
    }

    }

     编写完后运行,能运行访问就ok了

      觉得不错的可关注微信公众号在手机上观看,让你用手机边玩边看

  • 相关阅读:
    《将博客搬至CSDN》
    2015-05-01 至 2015-07-30错误总结
    2015-01-01至2015-04-30错误积累
    2015-07-30 至 2016-03-16错误Note
    2014-11-21错误总结
    Spring 和 SpringMVC 的区别
    spring 容器加载
    Spring注解
    自定义拦截器
    Js闭包
  • 原文地址:https://www.cnblogs.com/test-my/p/5941973.html
Copyright © 2011-2022 走看看