1

I'm using webdriver to click on a submit button on a form in an iframe. Basically:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys(Keys.RETURN)
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

I've also tried:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("#submit-endslide").click()
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

and:

self.driver.find_element_by_css_selector("[name~='field_1']").clear()
self.driver.find_element_by_css_selector("[name~='field_1']").send_keys("123")
self.driver.find_element_by_css_selector("#submit-endslide").submit()
self.driver.switch_to_window(self.driver.window_handles[-1])
self.assertEqual(self.driver.current_url, "http://fake_address.com")

I've been getting:

Traceback (most recent call last):
  File "test_ytplayer_smoke_form.py", line 198, in testSmallFormSubmission
    self.driver.find_element_by_css_selector("[name~='field_1']").send_keys(Keys.RETURN)
  File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 293, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing})
  File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 370, in _execute
    return self._parent.execute(command, params)
  File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 166, in execute
    self.error_handler.check_response(response)
  File "/home/giant/our_player/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 164, in check_response
    raise exception_class(message, screen, stacktrace)
TimeoutException: Message: u'Selenium took too long to run your command.

Then WebDriverException: Message: u'Due to a previous error, this job has already finished.

Regardless of which method I choose, I will always get a timeout when clicking the submit button; (I've already tried increasing the timeout to 300)

Note:When I watch the test run, the submit button is being clicked and a new tab will open, but the test will never pass due to the exceptions.

3
  • Your traceback says that sending RETURN fails. You are not clicking on submit button but sending RETURN to input field in your 1st example. You Do in 2nd example - was the traceback the same? . Also, you may want to save located element in a variable to make your code easier to follow. Also, consider reading up on WebDriverWait and ExpectedConditions, they make Se2 much smoother to use. Commented May 21, 2014 at 21:17
  • The traceback is the same. If the issue was related to the wait, I would expect to see a NoSuchElementException; The submit button IS getting clicked and the popup is appearing, but I can never get to the assert as I get a timeoutException as I click the submit button(or hit RETURN) Commented May 21, 2014 at 22:47
  • This issue is specific to Chrome V28. I don't know why anyone would use an old browser, so this question can be closed. Commented Jun 5, 2014 at 13:45

2 Answers 2

1

There seemed to be a browser specific issue Chrome V28 that was causing this issue; I updated to the latest browser version Chrome V35 and this seemed to be resolved

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

Comments

0

As my comment says, we need more info, but comments are ugly to edit, so I add more info here:

  • Instead of wait based on time, try WebDriverWait see here for start.
  • Store element in variable when found, like:

    field_1 = self.driver.find_element_by_css_selector("[name~='field_1']")
    field_1.clear()
    field_1.send_keys("123")
    submit = self.driver.find_element_by_css_selector("#submit-endslide")
    submit.click()

But try to use WebElementDrive and ExpectedConditions instead of driver methods directly.

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.