0

I would like to target a button that contains the name ="loginButton", and click the element after loading etc so it doesnt click on the loading spinner. How do I go about this webdriverwait targetting the name element?

from selenium.webdriver.support.wait import WebDriverWait 
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((find_element_by_name('loginButton'), "loginButton"))).click()
4
  • 1
    If you can't click it, it doesn't click it... If the delay is fixed you can use the time.sleep (yourdelay) function. Commented May 5, 2021 at 7:35
  • its a button so it definitely clicks, question is how do i go about doing the webdriverwait delay? is my code correct? Commented May 5, 2021 at 7:41
  • 1
    Does this answer your question? Selenium wait for element to be clickable python Commented May 5, 2021 at 7:48
  • prophet has the answer! Commented May 5, 2021 at 7:48

1 Answer 1

1

You are almost correct.
For the provided example try using following code:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.NAME, "loginButton")))

element.click();

See here for more explanations

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.