I want to press any keyboard key that is non-modifier key e.g. “Q”, “W”, “E” or “R”.
I tried sending send_keys
onto random element but it doesn’t work and selenium says that it cannot interact with that element. How can I send these keystrokes just in the website not onto specific element.
Advertisement
Answer
You can send and make key stroke events work in a website only if the website impliments a event catcher for these keystrokes. Browser level key stroke won’t trigger anything from selenium
you can send key stroke only to interactable elements (means enabled and accept keystrokes)
example you can send a key stroke like ctrl+a to full html as
driver.find_element_by_tag("body").send_keys(Keys.CONTROL+"a")
so you can send q,w,e, etc as
driver.find_element_by_tag("body").send_keys("q")
But it won’t do anything unless the website have an event handler for this key strokes