如何单击循环并单击所有具有属性的xpath并在控制台中打印以获取文本?

时间:2018-12-05 20:23:37

标签: java selenium selenium-webdriver

有一个包含12个链接的页面。我需要单击所有12个链接。 然后在另一个名称列中,单击“循环”后,我需要打印所有名称。

已解决

列表editicons1 = driver.findElements(By.xpath(“ // i [@ class ='material-icons']”)));         for(int j = 1; j <= editicons1.size(); j ++){             editicons1 = driver.findElements(By.xpath(“ // i [@ class ='material-icons']”)));             字符串porfolioName = driver.findElement(By.xpath(“(// mat-table // mat-row)[” + j +“] // mat-cell [2]”))                     .getText();             WebElement editicon = driver.findElement(By.xpath(“(// i [@ class ='material-icons'])[” + j +“]”)));             click1(驱动程序,editicon,porfolioName +“项目组合编辑图标”);             Thread.sleep(1000);             waitForElementPresent(驱动程序,30,buildportfolioheader);             Reporter.log(“成功呈现到投资组合的投资组合屏幕” + porfolioName);

0 个答案:

没有答案