Python/ Selenium is not sending tilde character (~) to the input field

。_饼干妹妹 提交于 2019-12-08 09:45:23

问题


I'm trying to use Python/ Selenium/ Webdriver to automatically fill an input field in my Chrome webpage. However, I am not able to use "send_keys" to fill out the tilde character.

Here is what I've tried so far:

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')

But the "~" tilde is not appearing on the field.

It is filled just as "charles18" instead of "charles~18"

Any help? Thanks!


回答1:


As per documentation you can call multiple time send_keys method.

Try this. 1. split url by ~ 2. send every fragmentation one by one. 3. only for ~ just send its unicode '\ue07E'

However this is not specify anywhere. but 7E is unicode for ~ special key mapping for selenium is here. Hope this help.

Java doc for selenium key is here



来源:https://stackoverflow.com/questions/48797295/python-selenium-is-not-sending-tilde-character-to-the-input-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!