码迷,mamicode.com
首页 > 其他好文 > 详细

selenium打开ie测试小实例

时间:2017-02-07 17:04:02      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:selenium

package mqTest;


import java.io.File;


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.ie.InternetExplorerDriver;

import org.openqa.selenium.remote.DesiredCapabilities;


public class testSelenium1 {


public testSelenium1() {

// TODO Auto-generated constructor stub

}


public static void main(String[] args) {

// TODO Auto-generated method stub


//WebDriver driver=new FirefoxDriver();

File file = new File("F:/IEDriverServer.exe");  

System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); 

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();

ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

WebDriver driver=new InternetExplorerDriver(ieCapabilities);

driver.get("https://www.baidu.com");

//WebElement loginLink=driver.findElement(By.partialLinkText("登"));

//loginLink.click();

/*页面代码

* <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off"></span><span class="bg s_btn_wr"><input type="submit" id="su" value="百度一下" class="bg s_btn">

*/

//用id

WebElement baiduTextBox = driver.findElement(By.id("kw"));

baiduTextBox.sendKeys("selenium");

WebElement button=driver.findElement(By.id("su"));

button.click();

}


}


本文出自 “测试” 博客,请务必保留此出处http://wanglidong.blog.51cto.com/8781265/1895545

selenium打开ie测试小实例

标签:selenium

原文地址:http://wanglidong.blog.51cto.com/8781265/1895545

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!