简体   繁体   中英

CSS expression is not working for Select link

table class="s-table table table-bordered table-striped table-hover">
<thead class="p-table-head">
<tbody class="p-table-body">
<tr>
<td>
<td>
<td>
<td>
<td>
<td>
<td>
<div id="div_2_1_2_1_7_r6" class="Action_Group CoachView CoachView_show" data-eventid="" data-viewid="Action_Group5" data-config="config_div_2_1_2_1_7_r6" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_9e739df9_ccc7_4dfa_9b75_8233150ad5bc.Action_Group">
<div id="div_2_1_2_1_7_1_r6" class="ContentBox" data-view-managed="true" style="display: none;"> </div>
<div class="s-action-group clearfix">
<div class="l-nodeId" style=" display: none; "></div>
<div class="p-action-group">
<div id="div_2_1_2_1_7_1_1_r6" class="Action CoachView CoachView_show" data-eventid="boundaryEvent_4" data-viewid="Action3" data-config="config_div_2_1_2_1_7_1_1_r6" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_9e739df9_ccc7_4dfa_9b75_8233150ad5bc.Action">
<button id="div_2_1_2_1_7_1_1_r6-lnk" type="button" style="display: none;">
<a class="p-action-link" href="#action" title="">
<i class="fa fa-user"></i>
<span>Select</span>
</a>
</div>
<div id="div_2_1_2_1_7_1_2_r6" class="Action CoachView CoachView_show" data-eventid="boundaryEvent_8" data-viewid="Action4" data-config="config_div_2_1_2_1_7_1_2_r6" data-bindingtype="" data-binding="" data-type="com.ibm.bpm.coach.Snapshot_9e739df9_ccc7_4dfa_9b75_8233150ad5bc.Action">
</div>
</div>
</div>
</td>
</tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>

</tbody>
</table>
</div>

I have tried x path expression as

  1. //div[@class='row-fluid']/table/tbody/tr[1]/td[7]/div/div[2]/div[2]/div/a/span

  2. //*[@id='div_2_1_2_1_7_1_1_r6']/a/span

Also tried CSS selector as

  1. div[id='div_2_1_2_1_7_1_1_r6'] a[class='p-action-link'] span

any of above identification is not working please let me know if any one has best solutions for the above problem!

Try this XPATH:

//a[span='Select']

If it is not working, please indent the HTML.

Try with below locators.

By.xpath("//div[@id='div_2_1_2_1_7_1_1_r6']//a//span")
or
By.xpath("//div[@id='div_2_1_2_1_7_1_1_r6']//a//span[text()='Select']")
or
By.xpath("//span[text()='Select']")
or
By.cssSelector("div[id='div_2_1_2_1_7_1_1_r6'] a span")

If that div id is not static (I mean dynamically generating unique id everytime) then you should consider some other attribute or some part of it.

By.xpath("//div[contains(@id,'div_2_1')]//a//span")
or
By.xpath("//div[contains(@id,'div_2_1')]//a//span[text()='Select']")
or
By.xpath("//span[text()='Select']")
or
By.cssSelector("div[id*='div_2_1'] a span")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM