1
我需要在我的網站中自動鏈接。我想在循環的每次迭代中傳遞一次xpath值。所以,我可以減少我的編碼
公共類彈出 {如何爲selenium java代碼添加循環條件
private WebDriver driver;
private String baseUrl;
//private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://www.example.com/info.php";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testPopup() throws Exception {
driver.findElement(By.xpath("//div[@id='info-list']/div[2]/div/div/div/div/a[2]/i")).click();
driver.findElement(By.xpath("//div[@id='info-list']/div[2]/div/div/div/div/a[3]/i")).click();
driver.findElement(By.xpath("//div[@id='info-list']/div[2]/div/div/div/div/a[4]/i")).click();
driver.findElement(By.xpath("//div[@id='info-list']/div[2]/div/div/div/div/a[5]/i")).click();