欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WebDriver實(shí)現(xiàn)自動(dòng)化打開(kāi)IE中的google網(wǎng)頁(yè)并實(shí)現(xiàn)搜索

 更新時(shí)間:2014年04月28日 09:13:05   作者:  
這篇文章主要介紹了WebDriver實(shí)現(xiàn)自動(dòng)化打開(kāi)IE中的google網(wǎng)頁(yè)并實(shí)現(xiàn)搜索,需要的朋友可以參考下

WebDriver實(shí)現(xiàn)自動(dòng)化打開(kāi)IE中的google網(wǎng)頁(yè)并實(shí)現(xiàn)搜索,需要導(dǎo)入WebDriver相關(guān)的jar包,設(shè)置好環(huán)境變量。

復(fù)制代碼 代碼如下:

package com.feng.domain;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class TestWebDriver {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  System.setProperty("webdriver.ie.driver", "C:\\testwebdriver\\IEDriverServer.exe");
  DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
  ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
  WebDriver driver = new InternetExplorerDriver(ieCapabilities);
  driver.get("http://www.google.com.hk/");
  try {
   Thread.sleep(6000);
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  // System.out.println("The current url is:" + driver.getCurrentUrl());
  WebElement element = driver.findElement(By.name("q"));
  element.sendKeys("days");
  WebElement elementBtn = driver.findElement(By.xpath("http://input[@name='btnG']"));
  elementBtn.click();
  try {
   Thread.sleep(6000);
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  driver.close();
 }
}

相關(guān)文章

最新評(píng)論