python selenium send_keys生成错误的ch

2024-04-23 16:29:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一台远程ubuntu机器上运行了一些测试,发现了一个奇怪的错误:

如果我试图使用send_键将这些键%/?^56发送到输入,它们不会到达那里。在

5 creates a backspace
6 creates a Shift+Tab
^ creates a Tab
% creates a backspace
? creates a Enter

这只发生在Chrome+Selenium+python2.7上

^{pr2}$

有什么线索可以让我开始调查吗?在

编辑:我用来调试这个的一些代码

from selenium.webdriver.common.keys import Keys
import time
import string
allchars = string.letters + string.punctuation + string.digits
from selenium.webdriver import Firefox
from selenium.webdriver import Chrome
b1 = Firefox()
b2 = Chrome()
b1.get("http://google.ro")
b2.get("http://google.ro")
i1 = b1.find_element_by_id('lst-ib')
i2 = b2.find_element_by_id('lst-ib')
for l in allchars:
    i1.send_keys(l)
    i2.send_keys(l)
    time.sleep(1)
    if i1.get_attribute('value') != l:
        print "mismatch",b1,l
    if i2.get_attribute('value') != l:
        print "mismatch",b2,l
    i1.send_keys(Keys.BACKSPACE)
    i2.send_keys(Keys.BACKSPACE)

EDIT2:在将包升级到ubuntu-x64可用的最新版本后,问题仍然存在,但仅限于这些字符%/?5。我要把这个贴到窃听器上。在


Tags: fromimportsendgetstringseleniumkeyschrome