开发者

Convert Xpath locator to CSS locator in Selenium

开发者 https://www.devze.com 2023-01-04 07:41 出处:网络
All, This xpath locator works fine in Firefox: ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_开发者_开发百科DDD_L_LBI2­T0

All,

This xpath locator works fine in Firefox:

ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_开发者_开发百科DDD_L_LBI2­T0

This does not work in IE. I have been trying to convert to CSS locator without success. The item I am trying to select is Seller. Here's the whole blob:

<div style="width: 168px; overflow: auto; height: 107px; padding-right: 0px;" class="dxlbd" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­D"> 
  <input type="hidden" name="ctl00$ctl00$mainPage$rightColumn$wholeControl$grid$cell2_3$roleX$DDD$L" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­VI" value="0">    
   <table cellspacing="0" cellpadding="0" border="0" style="width: 100%; border-collapse: separate;" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBT"> 
    <tbody> 
     <tr class="dxeListBoxItemRow"> 
      <td class="dxeListBoxItem  dxeListBoxItemSelected" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI0T0">Choose</td> 
     </tr> 
     <tr class="dxeListBoxItemRow"> 
      <td class="dxeListBoxItem" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI1T0">Buyer</td> 
     </tr> 
     <tr class="dxeListBoxItemRow"> 
      <td class="dxeListBoxItem dxeListBoxItemHover" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI2T0">Seller</td> 
     </tr> 
     <tr class="dxeListBoxItemRow"> 
      <td class="dxeListBoxItem" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI3T0">Buyer &amp; Seller</td> 
     </tr> 
     <tr class="dxeListBoxItemRow"> 
      <td class="dxeListBoxItem" id="ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI4T0">Observer</td> 
     </tr> 
    </tbody> 
   </table> 
  </div> 

Any ideas greatly appreciated.

Blake


There are a few ways that you could locate the seller cell. To locate it using CSS based on the content of the cell try:

css=td:contains(Seller)

If the id is static then the following should also work, however the id is unusually long, which could conceivably cause issues. I haven't tested this myself.

id=ctl00_ctl00_mainPage_rightColumn_wholeControl_grid_cell2_3_roleX_DDD_L_­LBI2T0
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号