2

I've been trying to fill in a web form using Selenium in Python. It's a simple enough task, and the code I'm using is this:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://...")
elem = driver.find_element_by_id("receipt_number")
elem.clear()
elem.send_keys("13lettercode")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

After inspecting the web form element I got this:

<input id="receipt_number" name="appReceiptNum" type="text" class="form-control textbox" maxlength="13">

The website gives me an error saying that my code is invalid, and I'm wondering if there's anything obvious that I'm doing wrong. Thanks for your help!

2
  • Please share exact error stacktrace... Commented Aug 29, 2016 at 23:47
  • And you want to only fill the form or navigate somewhere??? Also share whole login form HTML Commented Aug 29, 2016 at 23:49

1 Answer 1

1

click the submit button instead of sending a return key

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

1 Comment

Thanks! That got me a lot closer. I still get the error, but the page 'refreshes' and gives me the results after a short moment.

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.