Windows authentication using phantomjs

I am learning phantomjs as a possible solution for automating the user interface in my last project, but I cannot get Windows to check if it works correctly. I tried to set page.settings.userName and page.settings.password , but the screenshot below is set to 401 , and the base stack makes no effort to fix it. My search fu failed me, so I came to the community to ask for help.

 var page = require('webpage').create(); page.onResourceReceived = function(response) { phantom.exit(response.status); }; page.open('http://bing.com'); 
+6
source share
3 answers

For me, this case works fine. mike rogers solution

 var _driverOptions = new PhantomJSOptions(); var _driverService = PhantomJSDriverService.CreateDefaultService(); _driverOptions.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); _driver = new PhantomJSDriver(_driverService, _driverOptions); using (Impersonation.LogonUser(domain, login, pass, LogonType.Interactive)) { using (var proxy = new NtlmProxy(new Uri("http://yoursite.com/"), options)) { _driver.Navigate().GoToUrl(url); } } 
0
source

There is an open PhantomJS Issue with ongoing discussion. It seems that PhantomJS does not support (automatic / integrated) NTLM authentication, which means that it will not work against a server that requires integrated Windows authentication.

+2
source

You can add your domain credentials to the URL:

 var driver = new PhantomJSDriver(); driver.Manage().Window.Size = new System.Drawing.Size(1024, 1024); driver.Url = "http://myusername: mypassword@localhost /myapp"; 

I think it could be version 2, I'm not sure. AFAIK does not support the transfer of credentials of the current user, which is a shame.

0
source

Source: https://habr.com/ru/post/958423/


All Articles