Webdriver ????????????
???????????? ???????[ 2014/6/17 14:17:38 ] ????????Webdriver ?????????
???????????????????????????????locateelements?????????????????????????????????????????????
??????????????锟�?
????1.????????
????2.?????????????????????????纾簑ebdriverautomationtesting
????3.?????????button
????4.?????????????????????????
??????????????????????????锟�?
packagecom.example.tests;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.firefox.FirefoxDriver;
importorg.testng.Assert;
importorg.testng.annotations.AfterMethod;
importorg.testng.annotations.BeforeMethod;
importorg.testng.annotations.Test;
publicclassBaiDuSearchTest{
privateWebDriverdriver;
privateStringbaseUrl;
@BeforeMethod
publicvoidsetUp()throwsException{
//LaunchFirefoxbrowser
driver=newFirefoxDriver();
baseUrl="http://www.baidu.com";
}
@Test
publicvoidbaiDuSearchTest()throwsException{
StringexResult="WebDriverautomationtesting";
//Open???homepage
driver.get(baseUrl);
//Locatesearchboxandinputsearchkeyword
driver.findElement(By.id("kw1")).sendKeys("WebDriverautomationtesting");
//Click??????button
driver.findElement(By.id("su1")).click();
//???????????????link?????????????????????????
StringactResult=driver.findElement(By.id("1")).getText();
Assert.assertTrue(actResult.contains(exResult));
}
@AfterMethod
publicvoidtearDown()throwsException{
driver.quit();
}
}
|
???????????????java??????runasTestNGtest??????????????????????????????
??????????????????????????????????easy??
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11