0

I have created an script with Python using Selenium to access a third party website (sharepoint), authenticate, run a report and download an excel file to a folder. That works well. The problem is that when I want to automate this process with Windows Task Scheduler, it fails when trying to authenticate to the site since apparently the Shell.SendKeys functionality doesn't work in background processes. Popup

I was exploring other solutions to try to automatically authenticate and avoid the keyboard inputs since Selenium is not able to manage those kind of browser popups.

To achieve this and after hours of googling, I added the site to Trusted Sites in Internet Explorer and activated the option "Automatic Logon with current user name and password" Link

That worked in Internet Explorer, but when activated, I directly couldn't enter the site anymore from google Chrome which supposedly uses the same configuration for trusted sites from IE.

Error

I also regenerated the python code to run over Internet Explorer (where the automatic login in works), but I get other popup at the end of the process to confirm "Open/Save" File where again I cannot manage to confirm with Selenium and I'm forced to use Shell.SendKeys which doesn't work with Task Scheduler so I'm stuck with this!!.

Anyone can help me to find a workaround?. Thanks in advance.

fran
  • 1

2 Answers2

0

Try using the Robot Class. It is in Java, iI am assuming something like that would be there in Python.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Asjad Azeez
  • 53
  • 13
0

If it's a authentication popup (and not html), then its difficult to handle using selenium as alert does not identify those popup in python selenium. and chrome also does not support it (read more here & posted by others here )

If you want to avoid using keyboard inputs one option you can try is to send credentials in user similar to https://username:password@urlforwebsite. (make sure you use url escapes for special chars). this works for me.

If your call is not starting and in-between your workflow then you might need to intercept requests using selenium-wire. I haven't tried this but should work similar way to modify URL with username & pswd.

Only thing I am not able to achieve without keyboard input, is if your authentication pop-up is from automatically redirected different url.

Hope this helps.