我无法点击我的网页的超链接

时间:2018-02-07 06:55:04

标签: selenium selenium-webdriver automated-tests

被阻止的本地队列 ` 你能给我解决方案吗?点击超链接使用selenium webdriver。

HTML code:

   <tr> <td width="3%"></td> <td width="97%">Event Processing Status <table class="table1" width="100%"> <tbody><tr> <td width="3%"></td> <td width="97%"><a href="blockedLocalUsers.jsp"target="right">Blocked Local Queues</a></td></tr> <tr> <td width="3%"></td> <td width="97%"><a href="blockedRemoteUsers.jsp" target="right">Blocked Remote Queues</a> </td></tr> </tbody></table> </td></tr>

代码:

public class XPDMGatewayAdminPage { public static void main(String[] args) throws Exception {
     WebDriver driver=new FirefoxDriver();

    driver.get("aws-edgetc01:8080/XPDMGateway/admin/"); 

    driver.manage().window().maximize(); 

    driver.findElement(By.name("btnLogin")).click();

    WebDriverWait wait=new WebDriverWait(driver,40); 
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/ta
ble/tbody/tr[13]/td[2]/table/tbody/tr/td[2]/a"))); 

    driver.findElement(By.xpath("//td/a[@href='blockedLocalUsers.jsp' and text()='Blocked Local Queues']")).click(); 
}

2 个答案:

答案 0 :(得分:0)

您可以使用此xpath://a[text()="Blocked Local Queues"]

答案 1 :(得分:0)

你可以试试linkText:

WebElement MyAccountLink = driver.findElement(By.linkText("Blocked Local Queues"));
MyAccountLink.click();

希望它有效。

相关问题