Issue
I have a table with few rows where I have SiteName 1,2 and so on and next to each site name I have Edit button. I want to have a loop which clicks on all Edit buttons. However I get error when I want to click on some buttons and only on some are working properly however the code for all rows is exactly the same as you can see this example bellow.
wls = ["//*[contains(text(), 'SiteName 8')]//following-sibling::td//a[contains(., 'Edit')]",
"//*[contains(text(), 'SiteName 2')]//following-sibling::td//a[contains(., 'Edit')]",
"//*[contains(text(), 'SiteName 1')]//following-sibling::td//a[contains(., 'Edit')]"]
for i in wls:
# WL list
driver.find_element_by_xpath(i).click()
this is the following-sibling I am using and it works for Site 1,2,3 and so on but not for site 8.
I get this error message message:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (1783, 946). Other element would receive the click: ...
I also tried just to find the full xpath and still get the same error message however the button Edit is clickable and link is valid and working.
<tr>
<td class="application_name alt" align="left">SiteName 1</td><td class="alt action">
<div class="list-action">
<a class="btn default " href="https://link1.com">
<i class="fa fa-fa fa-edit">::before</i>
Edit
</a>
</div>
</td>
</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>
<td class="application_name alt" align="left">SiteName 8</td>
<td class="alt action"><div class="list-action">
<a class="btn default " href="https://link8.com">
<i class="fa fa-fa fa-edit">::before</i>
Edit
</a>
</div>
</td>
</tr>
Solution
Use Java script executioner click instead of click method.
for i in wls: # WL list
driver.execute_script("arguments[0].click();", driver.find_element_by_xpath(i))
Answered By - rahul rai
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.