在Eclipse中使用Maven配置WebDriver+Testng(1)

发表于:2014-3-06 11:06

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:purpose23    来源:51Testing软件测试网采编

  4. 打开cmd命令窗口,切换到my_testng_test文件夹,敲入命令:mvn eclipse:eclipse 回车出现Build Success信息,则创建Webdriver项目成功。
  5. 在eclipse中导入所建文件夹
  6. 在my_testng_test项目下新建Source Folder - src, 新建package - org.openqa.selenium.example并在package “org.openqa.selenium.example”下新建
Class (修改使用Selenium官网上的例子)
<span style="font-family:SimSun;font-size:12px;">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) {
System.setProperty("webdriver.firefox.bin", "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.baidu.com");
WebElement element = driver.findElement(By.name("wd"));
element.sendKeys("Cheese!");
element.submit();
System.out.println("Page title is: " + driver.getTitle());
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
</span>
  运行即可。
相关文章:
在Eclipse中使用Maven配置WebDriver+Testng(2)
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号