selenium使用testNG測(cè)試框架編寫webdriver腳本_05
關(guān)鍵字:testNG,maven,selenium版本,Firefox版本
遇到的問題:a.運(yùn)行時(shí)報(bào)The JAR file selenium-2.44.0/jcommander-1.29.jarhas no source attachment錯(cuò)誤->使用maven項(xiàng)目形式
b.運(yùn)行時(shí)報(bào)The path to the driver executable must beset by the webdriver.gecko.driver system PRoperty; for more information錯(cuò)誤->selenium與firefox版本不兼容造成的,需要引用selenium2.44.0的包(selenium3.0以下版本)
=============================================
1.eclipse中引入testNG插件
2.新建一個(gè)java項(xiàng)目并轉(zhuǎn)換成maven項(xiàng)目
3.在pom.xml文件中引入以下內(nèi)容
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
</dependency>
</dependencies>
4.項(xiàng)目中引入TestNG插件
5.新建testNG類并編輯以下內(nèi)容:
public class demo03 {
WebDriver driver;
@Test
public void f() {
driver.get("https://www.sogou.com/");
driver.findElement(By.id("query")).sendKeys("測(cè)試");
driver.findElement(By.id("stb")).click();
}
@BeforeMethod
public voidbeforeMethod() {
System.setProperty("webdriver.firefox.bin","D://firefox//firefox.exe");
driver=newFirefoxDriver();
}
@AfterMethod
public voidafterMethod() {
driver.quit();
}
}
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注