Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am trying to run selenium web driver(Firefox) test cases which will need a single sign on (web). Issue over here is i have to sign in manually with my OTP every time i tear down the test case. So i will have to enter my username, password and OTP(second password which is generated dynamically), which obvious is very tedious for hundreds of test cases. Any reference or suggestions to deal SSO with web driver would be of help!

Thanks in advance.

share|improve this question
    
Welcome to SQA, Reddy. The programmer who solves the pop-up dialog problem in Selenium once and for all will be a king among testers. In the mean time, have you tried searching this site for "Selenium authentication". –  user246 May 31 '12 at 12:30

1 Answer 1

This question comes up a lot. Here is a possible solution, but it will require some additional development. You could use a customized HTTP proxy that acts as a pass-through filter except when it sees an HTTP 401 response. In the latter case, the proxy would respond with authentication credentials of your choosing.

Here is how you might do it, in steps:

  1. Find an HTTP proxy that you can modify in whatever language you use for your test. For brevity, I will assume you are using Java, so you want an HTTP proxy written in Java. (See http://stackoverflow.com/questions/860362/write-http-proxy-in-java for more details on open source, Java, HTTP proxies.)
  2. Presumably you have some means of determining second, dynamically-generated password, and the details of that are not important. I will call that mechanism the "OTP oracle". You need to write a Java method that can ask the OTP oracle for the next OTP.
  3. Modify the HTTP proxy to respond to 401 responses by asking the OTP oracle for the next password and responding back to the server with a new HTTP request with the appropriate credentials.
  4. Embed the HTTP proxy in your test, i.e. code your test so that at start-up, it launches the HTTP proxy in a separate thread.
  5. Tell Selenium to launch the browser so that it uses your HTTP proxy.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.