Python / Selenium is not filling the tilde character (~)

0

I'm trying to use Python / Selenium / Webdriver to automatically populate an input field on my Chrome page. However, I am not able to use the "send_keys" command to fill in the tilde character (~).

Here's my code:

import os
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select

browser = webdriver.Chrome(executable_path=r"chromedriver.exe")

browser.get("https://mywebpageaddress")

browser.find_element_by_id("username").send_keys('charles~18')

The page is populated as "charles18" instead of "charles ~ 18".

Note: You can manually type "charles ~ 18" in this field via the browser.

Does anyone know how to solve it? Thanks!

    
asked by anonymous 15.02.2018 / 00:15

1 answer

0

It may be because send_keys sends the keys through a layer before the system keyboard driver. Since your keyboard has the Brazilian layout, the "~" is a mute key.

Just try to send the "~" twice, just like typing:

browser.find_element_by_id("username").send_keys('charles~~18')

(Of course, if this is the case, the problem will be serious if the same code has to run in the cloud, for example on the server or in an instance of Travis)

    
15.02.2018 / 14:12