Python Selenium脚本会删除密钥,但仅在VNC上使用时 [英] Python Selenium script drops keys but only when used on a VNC

查看:182
本文介绍了Python Selenium脚本会删除密钥,但仅在VNC上使用时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置:

  • 具有VNC连接到Debian计算机的Windows 10计算机
  • Windows上的VNC Viewer 5.3.3
  • vncserver(Xvnc版本TightVNC-1.3.9) 在Debian上
  • Windows 10 machine with a VNC connection to a Debian machine
  • VNC Viewer 5.3.3 on Windows
  • vncserver (Xvnc version TightVNC-1.3.9) on Debian

我在Debian机器上有一个Python/Selenium/Chromedriver脚本,可以将数据输入到网页上的文本框.失败的代码非常简单:

I have a Python/Selenium/Chromedriver script on the Debian machine that does data entry to text boxes on a web page. The code that is failing is very simple:

element = browser.find_element_by_path('//input[@name="ReqDocID"]')
element.clear()
element.send_keys(doc_id) # doc_id is a 3 character string

当我从Windows计算机设置到Debian的VNC会话并从X-windows桌面上的xterm运行脚本时,doc_id中的字符将被随机删除.在条目之间添加延迟没有任何区别.在使用JS输入期间,网页不会修改文本框的内容.同时使用Chrome和headlesschrome时会发生此问题.我确认我有一个新版本的chromedriver(修复了一个掉键问题),并且我的键盘设置为英语,以避免出现另一个已知问题.

When I set up a VNC session to Debian from the Windows machine and run the script from an xterm on the X-windows desktop, characters in doc_id are randomly dropped. Adding delays between entries did not make any difference. The web page does not modify the contents of the text box during entry using JS. The problem occurs using both Chrome and headlesschrome. I verified that I had a new version of chromedriver (fixed a drop key issue) and that my keyboard is set for English to avoid another known issue.

最后,经过数小时的故障排除,我发现了一些有趣的东西.如果我在Windows框上使用Putty直接将其SSH放入Debian(没有X-windows,没有VNC),然后运行脚本,它将完美地运行.当我在VNC桌面上运行相同的脚本时,由于字符被删除,每次都会失败.

Finally after several hours of troubleshooting I found something interesting. If I use Putty on the Windows box to ssh into Debian directly (no X-windows, no VNC) and then run the script it works perfectly. When I run the same script from the VNC desktop it fails every time due to characters being dropped.

有人知道为什么通过VNC连接运行脚本会有所作为吗?谢谢!

Does anyone have an idea why running the script over a VNC connection should make a difference? Thanks!

推荐答案

TightVNC的一个公开错误与在chromedriver中发送密钥有关. 问题1509:TightVNC:sendKeys()

There is an open bug for TightVNC related to sending keys in chromedriver. Issue 1509: TightVNC: sendKeys()

作为讨论中建议的解决方法,它在

As a workaround suggested in the discussion, it's not reproducible on vnc4server. You can try that.

这篇关于Python Selenium脚本会删除密钥,但仅在VNC上使用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆