1

Tried using selenium to send keys to a textbox, but it can't seem to find the element even after using explicit waits.

Note: I just started learning python so I may be missing something big here.

Selenium has been able to find all elements on the site until this page (not sure if it is a new page because URL doesn't change, but modules within the page do). I have tried all the possible element locating methods(XPATH, ID, CLASS_NAME, etc.,) but it can't seem to find this textbox element. I tried using it to locate other elements on the page but it doesn't seem to be able to find them either.

#My code:
#imported expected_conditions as EC
wait = WebDriverWait(browser, 15)
wait.until(EC.presence_of_element_located((By.XPATH, '// 
[@id="payment_amount_value"]')))

#Element:
  <input type="text" class="input-mini text_input span10" 
   id="payment_amount_value" aria-describedby="payment-amount-error- 
   message" data-submit="paymentAmount">

    #Error Message:
    Traceback (most recent call last):
      File "<string>", line 100, in <module>
      File "/anaconda3/lib/python3.6/site- 
   packages/selenium/webdriver/support/wait.py", line 80, in until
        raise TimeoutException(message, screen, stacktrace)
    selenium.common.exceptions.TimeoutException: Message: 
1

2 Answers 2

1

Thanks for your help, Moshe! Turns out the element was in an iframe and I had to switch into it using:

iframe = wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="billing-app-container"]/iframe')))
browser.switch_to.frame(iframe)
Sign up to request clarification or add additional context in comments.

1 Comment

You should except your own answer... you can click the V under the # of votes
0

Change your xpath:

wait = WebDriverWait(browser, 15)
the_input = wait.until(EC.presence_of_element_located((By.XPATH, '//input[@id="payment_amount_value"]')))
the_input.send_keys("Bla-bla")

Hope this helps you!

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.