1

I've been trying to figure out how to wait for an element to be loaded and then execute the click function in python.

The website I am talking about is: https://tempail.com/

As soon as I received an e-mail, I want the script to click on it and then execute further tasks.

I tried to solve this problem through the "Try/Except Function", but I always receive error messages.

Source of the site: https://i.sstatic.net/n2z6E.png

The problem is that the site uses generated IDs I can't use in the find_element_by function.

This is what I've tried so far: https://i.sstatic.net/LlN6f.png

With try, I wanted the script to wait until the site received the mail. As soon as the mail is in the inbox, it should click the link/the mail and open it.

Apart from that, I looked up for more solutions, but nothing really helped out, but with this code I always receive the following error:

Message: no such element: Unable to locate element: {"method":"css selector","selector":".epostalar ul li.mail a"}

Plus it doesn't even wait for the mail.

1
  • Which link would you like to click? TEMPAIL Commented May 31, 2019 at 11:25

1 Answer 1

1

As soon as you receive an e-mail, to invoke click() on it you have to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "ul.mailler li.mail a"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//ul[@class='mailler']//li[contains(@class, 'mail')]//a"))).click()
    
Sign up to request clarification or add additional context in comments.

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.