zoukankan      html  css  js  c++  java
  • 软件测试第四次博客作业2

    package com.GMH.test;

    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.WebDriverWait;


    public class Work1 {

    public void Test(){

    //如果浏览器没有默认安装在C盘,需要制定其路径
    System.setProperty("webdriver.firefox.bin", "E:\Program Files\Mozilla Firefox\firefox.exe");
    //System.setProperty("webdriver.ie.driver", "C:\Program Files\Internet Explorer\IEDriverServer.exe");

    //打开火狐浏览器
    WebDriver driver = new FirefoxDriver();
    //打开IE浏览器
    /*WebDriver driver = new InternetExplorerDriver();*/
    //如果做页面测试,建议用HttpUnitDriver,这种方式打开浏览器,而是在内存中运行,速度比较快
    //WebDriver driver = new HtmlUnitDriver();

    //打开要测试的页面
    driver.get("http://www.baidu.com/");
    System.out.println("打开链接——>");

    //设置等待超出的时间(100秒)
    WebDriverWait wait = new WebDriverWait(driver, 100);

    //找到页面元素,此处是搜索输入框
    WebElement txtSearchBox = driver.findElement(By.name("wd"));
    //设置页面元素的值,即往输入框中输入值
    txtSearchBox.sendKeys("selenium2");
    //找到搜索按钮,并点击它
    WebElement btn = driver.findElement(By.id("su"));
    btn.click();

    //关闭浏览器
    //driver.close();
    }
    }

  • 相关阅读:
    括号序列的dp问题模型
    粉刷匠
    木棍加工
    物流运输
    最短路图
    DP基础(线性DP)总结
    离散化
    树链剖分
    NOIP2016 “西湖边超萌小松鼠” 模拟赛
    NOI导刊 2009 提高二
  • 原文地址:https://www.cnblogs.com/guomeihong/p/5536220.html
Copyright © 2011-2022 走看看