NTLM authentication in firefox not working for sharepoint

1,102 views
Skip to first unread message

Alex

unread,
Aug 2, 2013, 10:38:11 AM8/2/13
to seleniu...@googlegroups.com
I want to write some ui test for one of our apps for Sharepoint but to this we need to log into Sharepoint and Selenium does not have support for this. We got the auto login to work for chrome and ie but FF refuses to work. i read all about setting the ntlm auth and trusted uri in about:config and i did but it won't work. i tried adding the domain as trusted(.domainname) i added the exact url for the page with the app, i tried adding the machine name where sharepoint is hosted, i tried everything i could find and everyone says it should work with these things but for me it does not(it writes the username and password in the fields but it wont submit it). Is there some external setting for security that might be preventing this from working since everywhere i looked everyone says that these settings solved their problems. i know i could use like an autoit script to simply send an enter key to log in but i would rather avoid using external tools and stick to pure selenium testing.

Krishnan Mahadevan

unread,
Aug 2, 2013, 11:01:59 AM8/2/13
to Selenium Users
Alex,

Perhaps you can try this.

FirefoxDriver fd = new FirefoxDriver();
org.openqa.selenium.security.UserAndPassword creds = new org.openqa.selenium.security.UserAndPassword(uname, pwd);
fd.switchTo().alert().authenticateUsing(creds);



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


On Fri, Aug 2, 2013 at 8:08 PM, Alex <datcu....@gmail.com> wrote:
I want to write some ui test for one of our apps for Sharepoint but to this we need to log into Sharepoint and Selenium does not have support for this. We got the auto login to work for chrome and ie but FF refuses to work. i read all about setting the ntlm auth and trusted uri in about:config and i did but it won't work. i tried adding the domain as trusted(.domainname) i added the exact url for the page with the app, i tried adding the machine name where sharepoint is hosted, i tried everything i could find and everyone says it should work with these things but for me it does not(it writes the username and password in the fields but it wont submit it). Is there some external setting for security that might be preventing this from working since everywhere i looked everyone says that these settings solved their problems. i know i could use like an autoit script to simply send an enter key to log in but i would rather avoid using external tools and stick to pure selenium testing.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/529e2fa7-803a-459c-9123-49219a4846df%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alex

unread,
Aug 2, 2013, 11:16:24 AM8/2/13
to seleniu...@googlegroups.com
What exactly is this?

org.openqa.selenium.security.UserAndPassword

i can't find this variable type anywhere. i haven't updated selenium for about 3 versions. is it something recent? ps i am using c# for the selenium tests.

Krishnan Mahadevan

unread,
Aug 2, 2013, 11:25:09 AM8/2/13
to Selenium Users
Alex,

I referred to the released javadocs [Selenium 2.33.0] and that is Java code. I dont know whats the corresponding class names in C#

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


Prasad Bodke

unread,
Aug 2, 2013, 11:26:13 AM8/2/13
to seleniu...@googlegroups.com
Hi Alex,

I did the same in my last project. follow below code and attach file.
rename LoginFF.txt to LoginFF.exe.

@BeforeMethod
    public void startDriver() throws Exception
    {
        baseUrl = "http://172.16.50.45/";
        //--------------------Window Authentication Start--------------------------
        try
        {
            profile = new FirefoxProfile();
            profile.setPreference("network.http.phishy-userpass-length", 255);
            profile.setPreference("network.automatic-ntlm-auth.trusteduris","mindgate");
            profile.setPreference("network.automatic-ntlm-auth.allow-non-fqdn", "true");
            profile.setPreference("network.ntlm.send-lm-response", "true");
            //Profile.setPreference("browser.download.dir", "D:\\java prj");
            //Profile.setPreference("browser.download.folderList", 2);
            //Profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip");
            //profile.setPreference("capability.policy.strict.Window.alert", "noAccess") ;
            //profile.setPreference("capability.policy.strict.Window.confirm", "noAccess") ;
            //profile.setPreference("capability.policy.strict.Window.prompt", "noAccess") ;

            dialog =  new String[]{ "C:\\loginFF.exe","Authentication Required","mindgate\\mgs1058", "mindgate@1234", "ok" }; // Path to exe file, window Name, userName, Password, OK/Cancel button.
            driver = new FirefoxDriver(profile);
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            driver.manage().window().maximize();
            pp1 = Runtime.getRuntime().exec(dialog); //this piece will run exe to enter username and password in AuthDialog and click on OK
            driver.get(baseUrl+"/GTOW/Home/LoginHome.aspx");
            Thread.sleep(1000);
            System.out.println("Driver started");
        }
        catch (Exception e)
        {
            System.out.println("Driver not started");
        }
        //--------------------Window Authentication END---------------------------
    }


    @Test
    public void testNewVesselCodeMaster() throws Exception
    {
        try
        {

            //Select Module name on home page
            driver.findElement(By.id("MainContent_dlstModuleImage_ImageButton1_2")).click();






Regards
Prasad Bodke
09320675131


On Fri, Aug 2, 2013 at 8:46 PM, Alex <datcu....@gmail.com> wrote:

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Prasad Bodke
9320675131
loginFF.txt

Venkataramana Reddy

unread,
Jan 8, 2014, 7:50:58 AM1/8/14
to seleniu...@googlegroups.com

Hi Krishnan,

I have tried in the way u said,  while running script is not passing the username and password to allert window.

here is the script.

String URL="http://team/myvirtusa/default.aspx";
        FF.get(URL);
        UserAndPassword user=new UserAndPassword("venkat","password");
        FF.switchTo().alert().authenticateUsing(user);

Krishnan Mahadevan

unread,
Jan 8, 2014, 9:25:07 AM1/8/14
to Selenium Users
Hmm.. on second thoughts it may actually not work. I checked the Selenium code base and this method is annotated with @Beta and the implementation in RemoteAlert has this

    public void authenticateUsing(Credentials credentials) {

      throw new UnsupportedCommandException("Not implemented yet");

    }


Take a look at this post : http://watirmelon.com/2012/06/27/automatic-firefox-authentication-when-using-selenium-webdriver-with-autoauth/



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


Ashok kumar

unread,
Jan 8, 2014, 10:44:16 AM1/8/14
to seleniu...@googlegroups.com
Alex,

We are using the ATU Utilities API for handling the Authentication as well as Uploading and downloading scenarios.


The Code looks similar to the below

For NTLM Authentication:

WindowElement authenticationElement = handler.findElementByName(
firefoxWindowElement, "Authentication Required");
WindowElement userNameElement = handler.findElementByNameAndLocalizedControlType(authenticationElement, "User Name:""edit");
handler.typeKeys(userNameElement, "admin");
WindowElement passwordElement = handler.findElementByNameAndLocalizedControlType(authenticationElement, "Password:""edit");
handler.typeKeys(passwordElement, "admin");
WindowElement okButton = handler.findElementByName(authenticationElement, "OK");
handler.click(okButton);



For Uploading:

WindowElement uploadElement = handler.findElementByName(firefoxElement,"File Upload");
WindowElement fileNamePath = handler.findElementByNameAndClassName(uploadElement,  "File name:""Edit");
handler.typeKeys(fileNamePath, "sample.txt");
WindowElement openButton = handler.findElementByName(uploadElement,"Open");
handler.click(openButton);


Visit http://automationtestingutilities.blogspot.in/ for downloading the library.

Regards
Ashok
Reply all
Reply to author
Forward
0 new messages