Search code examples
pythonxpathautomationgmail

Use selenium for python to automatically click on email from [email protected]


I want to automatically click on an email from [email protected] and I know there will be only one email from that person so it won’t be a problem with two identical emails.

I have tried to locate the XPath for the email and that works fine. But when i try to click on it with webdriver.find_element_by_xpath("XPath of the email").click() the XPath is not clickable.

enter image description here

As far as I tried I was only able to specify which row <tr></tr> i wanted to click on webdriver.find element_by_xpath("XPath of row").click() and it clicks on it.

enter image description here

Is it somehow possible to click on a row that contains a specific email?


Solution

  • You can use the below xpath to get the row that contains [email protected] span.

    Option 1:

    //span[@email='[email protected]']/ancestor::tr[@role='row']
    

    Option 2:

    //tr[@role='row'][.//span[@email='[email protected]']]
    

    Screenshot : enter image description here