How do I send a Keys.DELETE keystroke to a text field with the Selenium web tester? I'm trying to simulate the user typing in a field and then deleting what they typed to test the interactive autosuggestion feature. It should filter the list to items beginning with their query, then show all the possible suggestions again when they delete their query. Unfortunatley sending a .clear() doesn't work to un-filter the list again. Neither does send_keys('\127').
def get_suggestions():
driver.get('https://www.example.com/')
driver.find_element_by_css_selector('#searchQuery').click()
driver.find_element_by_css_selector('#searchQuery').send_keys('a')
sleep(0.5)
driver.find_element_by_css_selector('#searchQuery').send_keys(Keys.DELETE)
sleep(0.5)
for suggestion in driver.find_elements_by_css_selector('#search-form #suggestions'):
yield suggestion
How can I simulate the user pressing the delete button on their keyboard?