点击selenium webdriver中的javascript div链接

时间:2015-10-08 21:04:40

标签: selenium-webdriver

<td class="menubox22" colspan="2">
   <table cellpadding=0 cellspacing=0 border=0 class="mybox1">
      <tr>
         <td id="tdMenuBar" class="mybox1">
            <table id="tblMenuBar" border="0" cellspacing=0 cellpadding=0>
               <tr id="mytr">
                  <td id="PanelTable" onmouseover="this.className='menulevel1hl';" onmouseout="this.className='menulevel1norm'" class="menulevel1norm" onclick="PopupWin('Left',divMenu1,this,'.menuitempopuprownormal','.menuitempopuprowhighlight','','.menuitempopupscroll');">
                     &nbsp;Alerts&nbsp;
                  </td>
                  <td id="PanelTable" onmouseover="this.className='menulevel1hl';" onmouseout="this.className='menulevel1norm'" class="menulevel1norm" onclick="PopupWin('Left',divMenu2,this,'.menuitempopuprownormal','.menuitempopuprowhighlight','','.menuitempopupscroll');">
                     &nbsp;Inventory&nbsp;
                  </td>
                  <td id="PanelTable" onmouseover="this.className='menulevel1hl';" onmouseout="this.className='menulevel1norm'" class="menulevel1norm" onclick="PopupWin('Left',divMenu3,this,'.menuitempopuprownormal','.menuitempopuprowhighlight','','.menuitempopupscroll');">
                     &nbsp;RTAM Exclusion&nbsp;
                  </td>
                  <td id="PanelTable" onmouseover="this.className='menulevel1hl';" onmouseout="this.className='menulevel1norm'" class="menulevel1norm" onclick="PopupWin('Left',divMenu4,this,'.menuitempopuprownormal','.menuitempopuprowhighlight','','.menuitempopupscroll');">
                     &nbsp;Sales Order&nbsp;
                  </td>
                  <div id="divMenu20110329014658433878" name="actiondiv" style="visibility:hidden;position:absolute;border:">
                     <DIV myonclick="window.parent.location.href='/smcfs/console/order.search';">
                        Sales Order Console
                     </DIV>
                     <DIV myonclick="window.parent.location.href='/smcfs/console/shipment.search';">
                        Outbound Shipment Console
                     </DIV>
                  </div>

我正在尝试点击表格行中的销售订单控制台。我尝试使用xpath://*[@id='divMenu4']/div[1]进行访问,一旦点击“销售订单”链接就会显示,但我无法访问它。

2 个答案:

答案 0 :(得分:0)

鉴于div包含&#34;销售订单控制台&#34;点击&#34;销售订单&#34; td元素,这些xpath定位器应该完成这项工作。

对于&#34;销售订单&#34; td元素: // td [包含(text(),&#39;销售订单&#39;)]

对于&#34;销售订单控制台&#34;元件: // DIV [@name =&#39; actiondiv&#39;] / DIV [1]

答案 1 :(得分:0)

请在Xpath下面尝试: -

//td[@id='PanelTable'][4]

或更具体

//td[@id='PanelTable' and contains(text(),'Sales Order')]

如果仍然遇到任何问题,请回复我:)