- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
HYPERLINK /blog/1481446 webdriver API中文版
1.1???下载selenium2.0的lib包
HYPERLINK /p/selenium/downloads/list /p/selenium/downloads/list
?
官方UserGuide: HYPERLINK /docs/ /docs/
1.2???用webdriver打开一个浏览器
我们常用的浏览器有firefox和IE两种,firefox是selenium支持得比较成熟的浏览器。但是做页面的测试,速度通常很慢,严重影 响持续集成的速度,这个时候建议使用HtmlUnit,不过HtmlUnitDirver运行时是看不到界面的,对调试就不方便了。使用哪种浏览器,可以 做成配置项,根据需要灵活配置。
?
打开firefox浏览器:
??????? //Create a newinstance of the Firefox driver
??????? WebDriver driver = new FirefoxDriver();
?
打开IE浏览器
??????? //Create a newinstance of the Internet Explorer driver
System.setProperty(“ernetexplorer.bin”,”c:\\propram files\Internet Explorer\iexplorer.exe”);
??????? WebDriver driver = new InternetExplorerDriver ();
?
打开HtmlUnit浏览器
??????? //Createa new instance of the Internet Explorer driver ???
??????? WebDriver driver = new HtmlUnitDriver();
?
1.3???打开测试页面
对页面对测试,首先要打开被测试页面的地址(如: HYPERLINK / ),web driver 提供的get方法可以打开一个页面:
??????? // And now use the driver to visit Google
??????? driver.get();
1.4???GettingStarted
package org.openqa.selenium.example;
?
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.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
?
public class Selenium2Example?{
??? public static void main(String[] args) {
??????? // Create a newinstance of the Firefox driver
??????? // Notice that the remainder of the code relies on the interface,
?? ?????// not the implementation.
??????? WebDriver driver = new FirefoxDriver();
?
??????? // And now use this tovisit Google
???????driver.get();
??????? // Alternatively the same thing can be done like this
??????? // driver.navigate().to();
?
??????? // Find the text inputelement by its name
??????? WebElement element =driver.findElement(B(q));
?
??????? // Enter something to search for
???????element.sendKeys(Cheese!);
?
??????? // Now submit the form.WebDriver will find
您可能关注的文档
- CentOS6.3_64安装手册-计算机技术资料.doc
- disk分区方法-计算机技术资料.docx
- Eclipse中配置selenium+testng-计算机技术资料.docx
- Java+selenium环境搭建-计算机技术资料.docx
- LoadRunner脚本的参数设置-block篇-计算机技术资料.docx
- LR乱码问题汇总-计算机技术资料.docx
- pro-计算机技术资料.docx
- python webdriver初步印象-计算机技术资料.docx
- python webdriver处理iframe-计算机技术资料.docx
- python webdriver键盘操作-计算机技术资料.docx
文档评论(0)