zoukankan      html  css  js  c++  java
  • 第四次作业第二题

    package com.yyy.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 Test1 {

    @Test
    public void Test(){

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

    //打开火狐浏览器
    WebDriver driver = new FirefoxDriver();
    //如果做页面测试,建议用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();
    }

    }

  • 相关阅读:
    用C++实现从键盘输入两个数a和b,求两数中的最大值
    MongoDB学习笔记-1
    linux 配置ip地址
    linux 配置jdk 环境变量
    VMware Linux 共享文件夹 虚拟机无共享文件解决方法
    数据库动态参数
    js
    js分页
    mysql存储过程
    webconfig 中配置上传文件大小
  • 原文地址:https://www.cnblogs.com/yanyuanyuan/p/5538212.html
Copyright © 2011-2022 走看看