0

Website form select is disabled until the previous form has been completed.It takes some time for website to recognize the fill out. I try to use wait.until(EC.element_to_be_clickable((By.ID, "..."))), but it returns me a time exception error. I tried sleep(2), and it works. I am wondering if I can still use wait in this case.

1
  • You should specify how much time you want to wait until expected condition. In answer provided by KevGeo (driver, 30) means that your script will wait 30 seconds for required element and raise TimeOutException if it still not clickable Commented May 6, 2016 at 7:04

1 Answer 1

1

You question isn't clear. You should show what you have tried/accomplished so far in detail. However, from what I understand I will try to answer you question in general.

To wait for an element to be clickable the correct syntax would be:

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, 30).until(
EC.element_to_be_clickable((By.ID, "ID_of_the_element")));
element.click();

In this case I have used ID as the element locator. You can use others such as XPATH as well.

Hope the helps.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your reply and sorry for my confuse text. I used wait = WebDriverWait(browser, 10), and it returns me a time exception error. I assume 10 here is 10 secs. I am wondering whether the form(select option) is not clickable.
The select option is clickable, however you need do it using the right method. This is how I would click on a select option: labels = [list of required/desirable options/a single option]; element = driver.find_element_by_id(element_id); for option in element.find_elements_by_tag_name('option'): if option.text in labels: option.click(); Do let me know if this helps. :)
@YingheChen Please let me know if the above code snippet is difficult to understand, I would be glad to add it as an edit to my answer.
Thanks kev, I still have trouble clicking on the button. I think this might be caused by two things. One is that the current button is outside of browser screen, and I need to scroll down a little bit to see the button. I have tried to scroll down but still not work. Second is that this website is using ng-click, which I am not familiar with. Here is a screen shot of the code. workforothers.com/Yinghe/code.png Thank you again for your help.

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.