1

I have written a python selenium code which automates actions on a website. Once user authenticates the log in, selenium takes over the browser and does its thing. Everything works perfectly fine, however, I notice that the code may fail if user accidentally clicks anything on any links while selenium is running.

Is there a way to prevent manual inputs from the user? something like:

br = webdriver.chrome()
br.lock_manual_userinput()
James Z
  • 12,209
  • 10
  • 24
  • 44
kksagar
  • 267
  • 1
  • 3
  • 14

2 Answers2

1

There is no such thing. You can dedicate machine/s with limited access for running the automation or just be carful if you are working while running the scripts.

Guy
  • 46,488
  • 10
  • 44
  • 88
0

Selenium is purely used for automating of repeatative Manual Tasks. At this point it is worth to mention that Selenium mocks User Interactions.

Hence the statement once user authenticates the log in, selenium takes over the browser is pretty much speculative as attempting to Reconnect Selenium to previous Browsing Session is not viable.

Now the statement, "code may fail if user accidentally clicks anything" is pretty much expected as Selenium needs browser focus. As a result of any manual user interaction Selenium will loose focus and raise an error.

Finally, there is no other way to prevent manual inputs as mentioned earlier that Selenium mocks User Interactions. The best possible way to execute your Selenium based Automated Tests preventing manual inputs from the user would be to :

  • Set up a Test Bed with all the required Hardware and Software configuration.
  • Create the Test Bed in an isolated environment preferably in a Test Lab free from Manual Intervention.
  • Automate only the required usecases which needs no manual intervention.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352