Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 477
jmq Avatar asked Oct 16 '22 12:10

jmq


1 Answers

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.

like image 134
Rahul L Avatar answered Oct 21 '22 05:10

Rahul L