即将更新

webdriver 安装和配置

上一篇 / 下一篇  2014-05-22 22:21:40 / 个人分类:Selenium








package com.gd.test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestSample2 {
public static void main(String[] args){
//创建一个FirefoxDriver实例
//这个类依赖于接口而不是接口的实现
WebDriver driver= new FirefoxDriver();
//使用get方法访问Google
driver.get("http://www.google.com");
//使用下面这个方法也能够达到访问Google的目的
//driver.navigate().to("http://www.google.com");
//找到html输入框的name
WebElement element=driver.findElement(By.name("q"));
//输入要查找的内容
element.sendKeys("Cheese!");
//提交表单,WebDriver会自动找到我们需要提交的元素所在的表单
element.submit();
//打印网页的标题
System.out.println("Pagetitleis:"+driver.getTitle());

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

}


TAG:

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-17  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 1823
  • 日志数: 2
  • 建立时间: 2011-12-25
  • 更新时间: 2014-05-22

RSS订阅

Open Toolbar