zoukankan      html  css  js  c++  java
  • Java+Selenium环境搭建

    初学者---简单的selenium环境搭建:

    1. 安装JAVA环境

    2.下载eclipse

    3.下载firefox (不要最高版本,容易出现selenium不兼容问题)

    4. 下载selenium需要的jar包下载地址:http://pan.baidu.com/s/1gdVqOAf

    5. 打开eclipse,创建一个javaproject,如下截图:

    测试代码如下:

    package demo;

    import java.io.File;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.WebDriver.Navigation;

    import org.openqa.selenium.firefox.FirefoxDriver;

    public class FrieFoxDriverTest {
    public static void main(String[] args) {

    // TODO Auto-generated method stub
    System.out.println("start firefox browser...");
    //如果火狐浏览器没有默认安装在C盘,需要制定其路径
    System.setProperty("webdriver.firefox.bin","D:/Program Files (x86)/Mozilla Firefox/firefox.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.baidu.com");

    System.out.println("start firefox browser succeed...");
    // 获取页面元素
    WebElement input = driver.findElement(By.id("kw"));
    WebElement button = driver.findElement(By.id("su"));

    // 搜索Claudia值
    input.sendKeys("Claudia博客");

    button.click();
    }

    }

  • 相关阅读:
    win7下cygwin命令行颜色和中文乱码解决
    maven mirror
    maven命令
    dubbo获取错误ip
    eclipse netbeans 代码模板
    windows下配置Groovy
    c++ 载入内存中dll ,以及内存注入
    表达式求值的 计算器
    vc 编译器的一些精典报错
    内联汇编实现 memcpy 和 memset
  • 原文地址:https://www.cnblogs.com/claudia/p/Claudia.html
Copyright © 2011-2022 走看看