无法单击“部署”链接

时间:2017-03-03 12:52:28

标签: java selenium

无法通过selenium单击“部署”链接按钮。如何单击“环境”按钮?

代码如下:

<a title="Deployments, Level 1, 2 of 6" class="tree_link" 
    id="linkAppDeploymentsControlPage" href="/console/console.portal?_nfpb=true&amp;_pageLabel=AppDeploymentsControlPage" 
    onkeypress="checkKeyStroke(event);" onmouseover="mouseOverCall('AppDeploymentsControlPage', 'popup');" 
    onmouseout="mouseOutCall('AppDeploymentsControlPage');" 
    oncontextmenu="return startDisplayPopup('AppDeploymentsControlPage', 'popup', event);">Deployments</a>

<span id="placeholderAppDeploymentsControlPage"></span>

<a title="Deployments, Level 1, 2 of 6" href="/console/console.portal?_nfpb=true&amp;_pageLabel=AppDeploymentsControlPage">
    <img id="iconAppDeploymentsControlPage" src="images/spacer.gif" align="absbottom" alt="" 
        border="0" onmouseover="mouseOverCall('AppDeploymentsControlPage', 'popup');" 
        onmouseout="mouseOutCall('AppDeploymentsControlPage');" oncontextmenu="return startDisplayPopup('AppDeploymentsControlPage', 'popup', event);" 
        title="Deployments">
</a>

<img id="iconAppDeploymentsControlPage" src="images/spacer.gif" align="absbottom" alt="" 
        border="0" onmouseover="mouseOverCall('AppDeploymentsControlPage', 'popup');" 
        onmouseout="mouseOutCall('AppDeploymentsControlPage');" oncontextmenu="return startDisplayPopup('AppDeploymentsControlPage', 'popup', event);" 
        title="Deployments">

我尝试使用下面的代码选项,但它仍然没有反映我的更改或无法点击部署链接:

driver.findElement(By.className("iconAppDeploymentsControlPa‌​ge")).click(); 
//driver.findElement(By.className("formButton")).click(); 
//driver.findElement(By.className("iconAppDeploymentsContr‌​olPage")).click(); 
//driver.findElement(By.className("tree_link")).click(); 
//driver.findElement(By.xpath("//img[@ src='images/shim.gif']")).click(); 
//driver.findElement(By.className("images/spacer.gif")).cl‌​ick(); 
//driver.findElement(By.className("Deployments")).click(); 
//driver.findElement(By.className("wlsc-titlebar-button-pa‌​nel")).click();

1 个答案:

答案 0 :(得分:0)

如果您尝试点击带有文字&#34;部署&#34;的链接。你可以这样做:

driver.findElement(By.xpath("//a[text()='Deployments']")).click();