0

Please note, this question is Python 3.5.2, only Python answers will be accepted. Unless this can definitely be handled in Java? Automating a process as part of an internal project. Everything works just fine using the IE webdriver, but not phantomJS web driver (which is expected due to limited functionality). However, a work-around / solution is required.

When opening the internal site, a Windows Security login dialog box comes up prompting for a username, password and press 'Ok'. With the IE web driver, it is handled just fine with:

loginAlert = driver.switch_to_alert()
loginAlert.authenticate(username, password)

The javascript:

driver.execute_script("window.confirm = function(){return true;}")

Being run before loading the page that gives the prompt, doesn't seem to confirm the login alert, for either phantom or IE. Even if it did, this doesn't type in the login details. As mentioned, it's a Windows Security prompt from the browser, not an element.

Once logged in, the page is reloaded with an ASP.NET_SessionId Cookie which expires once the session is ended. I've tried logging in through IE, then adding the cookie into Phantom, but it doesn't seem to match up the domains.

I've tried using:

driver.save_screenshot(filename) to see what's happening in phantom

Which works with IE driver, but with PhantomJS, only a transparent image is saved. The whole http://username:[email protected] thing doesn't work for either IE or phantom driver. It can't load / use the URL when this is done.

How can the Windows Security login dialog be handled, or worked around? I tried looking into alternatives, such as pyvirtualdisplay, but found no information on how to get this working with Python 3 on windows.

I have also tried setting phantomjs desired capabilities custom header authentication, but that doesn't seem to do anything for this either.

I have also tried using ActionChains, however they don't work when the Alert is there (in either IE or phantom driver). An UnexpectedAlertPresentException is thrown, even if this is caught and you try to perform the actions, once caught, the alert seems to close.

1 Answer 1

0

My bad!

Whilst the username:[email protected] didn't work in the IE webdriver - it did work in the PhantomJS web driver.

However, the website has limited browser compatibility - it doesn't load properly in either Chrome or Firefox, it is IE particular.

PhantomJS seems to handle the site the same way as Chrome / Firefox based on page source comparisons.

As such, I am trying to find a way to make the current IE driver invisible / hidden.

I have found:

headless-selenium-for-win using Python

However, despite the user here saying they got it to work, when I try to initialize the driver, it just hangs, the code doesn't proceed and no error messages are provided.

Asking another question regarding this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.