2

So I'm trying to learn about interacting with elements, after they are loaded (or enabled/interactable). In this case pressing button enables Edit box (after like 3-4secs), so you can write something. Here's link: http://the-internet.herokuapp.com/dynamic_controls

Here is how it looks now - works, but what if this edit-box would load, for example, 6 seconds? Then it'd be wrecked up...

enable = browser.find_element(By.XPATH, "/html/body/div[2]/div/div[1]/form[2]/button")
enable.click()
time.sleep(5)
fillform = browser.find_element(By.XPATH, "/html/body/div[2]/div/div[1]/form[2]/input")           
fillform.send_keys("testtt")
time.sleep(1)

I also tried browser.implicitly_wait(20) but it is like ignored and does nothing. Browser just keeps closing, because it can't find ENABLED edit box. It gives the error:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

I've tried another method for this - didn't work, as well...

element = WebDriverWait(browser, 5).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[2]/div/div[1]/form[2]/input")))

I am using Chrome+Python.

1
  • after clicking the "Enable" button wait for input box to be intractable using WebDriver Wait
    – Deepak Rai
    Commented Nov 21, 2022 at 11:17

1 Answer 1

2

Use WebDriverWait() and wait for element_to_be_clickable(). Also use the following xpath option.

driver.get('http://the-internet.herokuapp.com/dynamic_controls')
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Enable']"))).click()
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, "//form[@id='input-example']//input"))).send_keys("testtt")

browser snapshot:

enter image description here

1
  • 1
    Okay, it finally did the work! You used different elements than I used, I see
    – michalb93
    Commented Nov 21, 2022 at 11:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.