Python Selenium script drops keys but only when used on a VNC

白昼怎懂夜的黑 提交于 2020-02-24 09:05:29

问题


Setup:

  • 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

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

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.

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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/57431513/python-selenium-script-drops-keys-but-only-when-used-on-a-vnc

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