I am currently programming the examples in "Test-Driven Development with Python", more specifically the first functional test. But for some weird reason, send_keys does not work properly. This is what I'm trying right now - and I changed the implicit wait for explicit waits, by the way!
inputbox = self.browser.find_element_by_id('id_new_item')
self.assertEqual( # This passes, it's here just for completeness
inputbox.get_attribute('placeholder'),
'Enter a To-Do item'
)
inputbox.send_keys('Buy peacock feathers')
inputbox.send_keys(Keys.ENTER) # Everything okay up to here
WebDriverWait(self.browser, 10).until(
EC.text_to_be_present_in_element((By.CSS_SELECTOR, "table#id_list_table tr td"), "Buy peacock feathers")
)
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('tr')
self.assertIn('1: Buy peacock feathers', [row.text for row in rows])
inputbox1 = self.browser.find_element_by_id('id_new_item') # Changed the variable only to test if it would hang too - and it does
inputbox1.send_keys('Use peacock feathers to make a fly')
inputbox1.send_keys(Keys.ENTER) # This hangs
self.fail()
WebDriverWait(self.browser, 10).until(
EC.text_to_be_present_in_element((By.CSS_SELECTOR, "table#id_list_table tr td"), "Use peacock feathers to make a fly")
)
It never reaches self.fail(). I tried moving it to the previous line, and the test fails, as it should. But inputbox1.send_keys(Keys.ENTER) never works, and when I see the browser as the test runs, inputbox1.send_keys('Use peacock feathers to make a fly') never writes "Use peacock feathers to make a fly" in the input box.
What is happening? I am using the latest Selenium (I think, I downloaded it a couple days ago just checked, I do have the latest version), Python and Django versions, and this opens Firefox Developer Edition in my laptop. Thank you.
EDIT: I tried disabling multi-process in Firefox, but the outcome does not change - it still hangs when trying to write and press enter.
inputbox1.send_keys(Keys.RETURN)?