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();
    }

    }

  • 相关阅读:
    分页
    uuid算法
    mysql卸载安装
    安装和破解收费版idea
    css样式一开始不显示,点击显示隐藏
    各种技术网址
    vue加载高德地图,加标记点,点出文本框
    Security Traps 玩耍剧透(持续更新)
    最近做的一个小玩意踩的坑
    最近刷题的一个总结
  • 原文地址:https://www.cnblogs.com/dieyaxianju/p/5033410.html
Copyright © 2011-2022 走看看