Safari 中的文本框未从 Selenium+Python 脚本中获取整个字符串
Textbox in safari is not taking the entire string from Selenium+Python Script
我在 Safari 浏览器上 运行 以下代码,使用 Selenium 和 Python。
player=driver.find_element_by_xpath("//*[@id='settings-stream-confirm']").clear()
player.send_keys("test123")
每次 send_keys 只在文本框中输入字符串的第一个字母,即 "t"。知道如何将整个字符串输入文本框吗?
野生动物园:13.0
Selenium:3.141.0
Python:3.7
请尝试使用 ActionChains
或 .execute_script
- 动作链:
player = driver.find_element_by_xpath("//*[@id='settings-stream-confirm']")
action = ActionChains(driver)
action.move_to_element(player).send_keys('test1234').perform()
- .execute_script:
player = driver.find_element_by_xpath("//*[@id='settings-stream-confirm']")
driver.execute_script("arguments[0].value = 'test1234';", player)
顺便说一句,根据问题中的代码,你错误 player
初始化,请删除 .click()
我在 Safari 浏览器上 运行 以下代码,使用 Selenium 和 Python。
player=driver.find_element_by_xpath("//*[@id='settings-stream-confirm']").clear()
player.send_keys("test123")
每次 send_keys 只在文本框中输入字符串的第一个字母,即 "t"。知道如何将整个字符串输入文本框吗?
野生动物园:13.0 Selenium:3.141.0 Python:3.7
请尝试使用 ActionChains
或 .execute_script
- 动作链:
player = driver.find_element_by_xpath("//*[@id='settings-stream-confirm']") action = ActionChains(driver) action.move_to_element(player).send_keys('test1234').perform()
- .execute_script:
player = driver.find_element_by_xpath("//*[@id='settings-stream-confirm']") driver.execute_script("arguments[0].value = 'test1234';", player)
顺便说一句,根据问题中的代码,你错误 player
初始化,请删除 .click()