Selenium send_keys doesn't sent apostrophe
To send the character sequence hello'world within the search box of Google Home Page you need to induce WebDriverWait for the element_to_be_clickable()
and you can use the following Locator Strategy:
Using
CSS_SELECTOR
:from selenium import webdriverfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECdriver.get("https://google.com")text = "hello'world"textbox = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "q")))for i in text: textbox.send_keys(i)
Browser Snapshot:
Update
Seems previously there were some issues with the non-US keyboard settings and Unicode characters while invoking send_keys()
. You can find a couple of relevant discussions in:
- SendKeys does not work correctly with non-US keyboard settings
- send_keys("é") to IE11 element sends e instead of é
- 3.5.0 Grid - Selenium Keys / Unicode Failing
This issue was solved through the commit Fixing encoding of payload passed by hub to a node.
Using Selenium v3.5.3 should solve this issue.
tl; dr
Solution:Changed from Chromedriver to Firefox using geckodriver. The single and double quote seems to ge glitched in the current version of Chromedriver.