【发布时间】:2020-05-16 12:28:19
【问题描述】:
在 Selenium 中,我想输入一个测试字符串 "hello'world",但网页的文本框变成了 "helloworld"。好像撇号不存在一样。将"'" 替换为chr(39) 或拆分字符串也不起作用。
- 我的部分代码:(在python中使用Chrome webdriver)
driver = webdriver.Chrome()
driver.get("https://google.com")
text = "hello'world"
textbox = driver.find_element_by_xpath('//*
[@id="tsf"]/div[2]/div[1]/div[1]/div/div[2]/input')
for i in text:
textbox.send_keys(i)
sleep(0.1)
【问题讨论】:
-
尝试使用 text = “hello”+”'”+ “World”。有时会因为键盘布局而出现此问题。
标签: python selenium selenium-webdriver webdriverwait sendkeys