zoukankan      html  css  js  c++  java
  • 【cl】selenium实例2:打开百度,输入hello world

    /*创建的类为junit class*/

    package Selenium_lassen;

    import static org.junit.Assert.*;

    import java.io.File;

    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxBinary;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class Case2 {

    WebDriver driver;
    @Before
    public void setUp() throws Exception {
    //方法一
    // System.setProperty("webdriver.firefox.bin", "D:\ruanjian\Firefox\azml\firefox.exe");
    //方法二
    // DesiredCapabilities capability=DesiredCapabilities.firefox();
    // capability.setCapability("firefox_binary","D:\ruanjian\Firefox\azml\firefox.exe");
    //driver = new FirefoxDriver(capability);
    //方法三
    File pathToFirefoxBinary = new File("D:\ruanjian\Firefox\azml\firefox.exe");
    FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
    driver = new FirefoxDriver(firefoxbin,null);
    }


    @Test
    public void test() throws Exception{
    driver.get("http://www.google.com.hk");
    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("hello Selenium!");
    element.submit();
    }

    @After
    public void tearDown() throws Exception {
    System.out.println("Page title is:"+driver.getTitle());
    driver.quit();
    }

    }

  • 相关阅读:
    单层感知机实现或运算
    Ubuntu关于eclipse新插件不显示的解决方案
    台州学院maximum cow训练记录
    利用矩阵快速幂转换的题目
    A Few Laughing Men
    TOJ1196: RSA Signing
    HDU
    2018“百度之星”程序设计大赛
    2018 “百度之星”程序设计大赛
    2018 “百度之星”程序设计大赛
  • 原文地址:https://www.cnblogs.com/dieyaxianju/p/5033410.html
Copyright © 2011-2022 走看看