1

I know there are similar questions already but none of those answers helped me.

I'm having some issues with the following. I've got the following tabs:

enter image description here

The HTML code for that particular section looks like this:

<td class="Tab1TblSelTd"><div class="Tab1SelTxtNew" title="Current Selection: Common Tasks">Common Tasks</div></td>
<td><a href="../task/Home?Home.tabCommon.TabHref=1&amp;jato.pageSession=AKztAAVzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAABHQADGN1cnJlbnRSZWFsbXQAAS90ABRDQ1RhYnMuU2VsZWN0ZWRUYWJJZHQAATB0ABVvcGVuc3NvLlNlbGVjdGVkVGFiSWR0AAEwdAASQ3VycmVudFByb2ZpbGVWaWV3dAABL3g$" name="Home.tabCommon.TabHref" class="Tab1Lnk" title="Click to configure access control" onmouseover="window.status='Click to configure access control'; return true" onmouseout="window.status=''; return true" onblur="window.status=''; return true" onfocus="window.status='Click to configure access control'; return true">Access Control</a></td>
<td><a href="../task/Home?Home.tabCommon.TabHref=2&amp;jato.pageSession=AKztAAVzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAABHQADGN1cnJlbnRSZWFsbXQAAS90ABRDQ1RhYnMuU2VsZWN0ZWRUYWJJZHQAATB0ABVvcGVuc3NvLlNlbGVjdGVkVGFiSWR0AAEwdAASQ3VycmVudFByb2ZpbGVWaWV3dAABL3g$" name="Home.tabCommon.TabHref" class="Tab1Lnk" title="Click to go to Federation" onmouseover="window.status='Click to go to Federation'; return true" onmouseout="window.status=''; return true" onblur="window.status=''; return true" onfocus="window.status='Click to go to Federation'; return true">Federation</a></td>
<td><a href="../task/Home?Home.tabCommon.TabHref=4&amp;jato.pageSession=AKztAAVzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAABHQADGN1cnJlbnRSZWFsbXQAAS90ABRDQ1RhYnMuU2VsZWN0ZWRUYWJJZHQAATB0ABVvcGVuc3NvLlNlbGVjdGVkVGFiSWR0AAEwdAASQ3VycmVudFByb2ZpbGVWaWV3dAABL3g$" name="Home.tabCommon.TabHref" class="Tab1Lnk" title="Click to go to Configuration" onmouseover="window.status='Click to go to Configuration'; return true" onmouseout="window.status=''; return true" onblur="window.status=''; return true" onfocus="window.status='Click to go to Configuration'; return true">Configuration</a></td>
<td><a href="../task/Home?Home.tabCommon.TabHref=5&amp;jato.pageSession=AKztAAVzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAABHQADGN1cnJlbnRSZWFsbXQAAS90ABRDQ1RhYnMuU2VsZWN0ZWRUYWJJZHQAATB0ABVvcGVuc3NvLlNlbGVjdGVkVGFiSWR0AAEwdAASQ3VycmVudFByb2ZpbGVWaWV3dAABL3g$" name="Home.tabCommon.TabHref" class="Tab1Lnk" title="Click to go to Sessions" onmouseover="window.status='Click to go to Sessions'; return true" onmouseout="window.status=''; return true" onblur="window.status=''; return true" onfocus="window.status='Click to go to Sessions'; return true">Sessions</a></td>
</tr>
</table>

And I want to click on Access Control.

This is what I'm trying to use:

wait.until(ec.presence_of_element_located((By.LINK_TEXT, 'Access Control'))).click()

Which apparently finds the elemen OK, but it doesn't click on it. There are no exceptions or messages of any kind, it simply doesn't click it.

I've used this approach with other links before, and it worked no problem, so I'm pretty sure I must be doing something wrong here.

Can you help?

Thanks!

1
  • Click on it implies program moves to next line without throwing any error ? Commented Aug 21, 2018 at 16:46

2 Answers 2

4

As per the HTML you have shared to invoke click() on the element with text as Access Control instead of using the method presence_of_element_located() you need to use the method element_to_be_clickable() and you can use either of the following solution:

  • Using LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Access Control"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.Tab1Lnk[title$='access control']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='Tab1Lnk'][contains(@title,'access control')]"))).click()
    

Note : You have to add the following imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

1 Comment

That fixed it. Thanks very much!
0

Try to click parent td element instead of a, xpath:

//td[./a[.='Access Control']]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.