zoukankan      html  css  js  c++  java
  • selenium小例子

    package test.seleniumTest;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import bsh.commands.dir;

    public class AutoTest1 {

        public static void main(String[] args) {
           System.out.println("----------init------------");
    //       System.setProperty("webdriver.ie.driver", "E:/Test/selenium/IEDriverServer.exe");
           System.setProperty("webdriver.chrome.driver", "E:/Test/selenium/chromedriver.exe");
           // 创建一个 ChromeDriver 的接口,用于连接 Chrome,
           //必须要有chromedriver.exe文件,selenium默认不能启动chrome
           // 创建一个 Chrome 的浏览器实例
            WebDriver driver = new ChromeDriver();
            driver.get("http://www.baidu.com");
            
            WebElement element = driver.findElement(By.xpath("//*[@id='kw']"));
    //        WebElement element = driver.findElement(By.name("q"));
            element.sendKeys("hello selenium");
            WebElement element1 = driver.findElement(By.xpath("//*[@id='su']"));
            element1.click();
            
          //等待,超时则抛出错误
            try {
             Thread.sleep(3000);
            } catch (InterruptedException e) {
             e.printStackTrace();
            }
            
          //关闭所有webdriver进程,退出
            driver.quit();
            System.out.println("----------end------------");
        }

    }

  • 相关阅读:
    Hystrix框架4--circuit
    Hystrix框架3--线程池
    undo tablespace RETENTION GUARANTEE
    Xshell访问虚拟机
    SQL Server nvarchar(max)
    win10 D盘空间占用太大(内容和标题可能不符,慎入)
    Grid Control安装和Deployment agent
    /etc/oratab
    Environment variable ORACLE_UNQNAME not defined.Please set ORACLE_UNQNAME to database unique name.
    Oracle的listener.ora、tnsnames.ora的配置
  • 原文地址:https://www.cnblogs.com/dandanfight/p/5915579.html
Copyright © 2011-2022 走看看