Monday, November 14, 2011

Handling Authentication dialog box using Selenium and AutoIT

As we know Selenium is an automation tool for web based applications and it handles only web elements and popups which triggered from web pages. Sometimes we get Window based popups like Authentication dialog box, Security warnings while using the web pages. The question would be how to handle these popups from Selenium?

The answer would be there is no straight forward method or command in selenium to handle these popups. We can use getAlert() and ChooseOKOnNextConfirmation() methods only when the popups are triggered from web pages.

In this scenario, we need to go for AutoIT scripts which can handle these kind of popups. These scripts can be integrated with Selenium code. Follow these steps to handle Authentication dialog box using Selenium and AutoIT.

1. Download AutoIT tool. It can be downloaded from http://www.autoitscript.com/site/autoit/downloads/

Note: Please download AutoIT Full Installation

2. While installing AutoIT, you will get two options: Run the Script and Edit the Script. If you are going to use the script without any modification, choose Run the Script option. If you want to customize the scripts, choose Edit the Script option (Recommended as we always needs to customize the scripts for our needs. Sometimes we need to create our own scripts.)

3. Once installed you can find all the sample scripts in the Example folder. Assume we have a sample script for handling the Authentication box which is Login.au3 (extension of the AutoIT scripts will be .au3). Right click on that file and choose Edit option. Find the script below:


WinWaitActive("Authentication Required","","20")
 If WinExists("Authentication Required") Then
 Send("userid{TAB}")
 Send("password{Enter}")
 EndIf
4.Customize the scripts according to your need. 
For example, You can type your username and password in the script.
WinWaitActive("Authentication Required","","20")
 If WinExists("Authentication Required") Then
 Send("selenium_user{TAB}")
 Send("selenium123{Enter}")
 EndIf

5. Save the file once you modify all the required changes.

6. Now, open the application Aut2Exe which will convert your AutoIT script into EXE format.



7. Now, call this EXE file from your selenium code as below.

@Test
public void testUntitled()
{
         Runtime run = Runtime.getRuntime();
         Process pp=run.exec("C:\\Program Files\\AutoIt3\\Examples\\Login.exe");
         selenium.open(URL);
         ...................
         ...................
}

8. Execute you selenium code and check if the AutoIT script handles the Authentication Required dialog box.

Even we can handle File Save As, Open With dialog boxes using AutoIT and Selenium. It will be covered in my coming blogs. Stay connected :-)

103 comments:

  1. Thanks for the solution... I am stuck with OK button at last.
    I implemented below code

    WinWaitActive("Authentication Required","","20")
    If WinExists("Authentication Required") Then
    Send("UserID{TAB}")
    Send("Pass{Enter}")
    Send("{OK}")
    EndIf

    But it is not clicking on OK button to login to http window.

    Please help me out
    shailendra.k.pal@gmail.com

    ReplyDelete
  2. Instead of Send("{OK}") try using Send("{Enter}")

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hi, The above solution works only in Firefox browser. Unfortunately it doesn't work in IE 8 and chrome. Could you pls help.

      Delete
    2. Yes, thats true- code is not working-chrome and IE

      Delete
    3. ShellExecute("@site")
      AutoItSetOption("WinTitleMatchMode","2")
      WinWait("Untitled - Google Chrome")
      $title = WinGetTitle("Untitled - Google Chrome") ; retrives whole window title
      $UN=WinGetText($title,"User Name:")
      ControlSend($title,"",$UN,"demo");Sets Username
      $PWD=WinGetText($title,"Password:")
      Send("{TAB 1}")
      ControlSend($title,"",$PWD,"tools");Sets PWD
      Send("{ENTER}")

      Delete
    4. hi, any working solution for chrome browser?

      Delete
  4. HI if my system is locked then probably its not being able to focus on authentication window.How can i achieve this so that my test cases should nt break even if i am not logged on to my system.

    ReplyDelete
  5. SWIFT Interview questions on

    http://testwithus.blogspot.in/p/swift.htm

    For selenium solution visit
    http://testwithus.blogspot.in/p/blog-page.html

    ReplyDelete
  6. Really good ,this is great helpful!!!!!!!!!!!!!!

    ReplyDelete
  7. Thanks Veera - This Post help me to solve my Windows Authentication but, As a User I'm not able to see the username and password type on the screen.Window Security prompt/modal pop up is appearing and after few seconds going to next screen. On Entering the the username and password, Can we see the typed username and password(in hidden)

    ReplyDelete
  8. thanks a lot for the wonderful information and it is useful for us.123trainings provides best SELENIUM online training.

    ReplyDelete
  9. Thanks for the wonderful information and it is useful forselenium Learners.123trainings provides best online SELENIUM training.

    ReplyDelete
  10. Excellent post
    Also Go through blog http://bugreaper.blogspot.in/

    U will find cool snippets of all most widely used actions in selenium

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Check this one, it worked for e without Auto it

    http://bugreaper.blogspot.in/2013/09/handling-authentication-dialog-box-in-selenium-webdriver.html

    If u like it join my blog for more updates

    ReplyDelete
  13. Hyderabadsys online Training is a one of the Top Online Training and giving quality Training on Selenium. Hyderabadsys have Experienced and corporate trainers will share their knowledge during the classes. Our documents for Selenium course through word format are specially designed by our trainers for Students..
    Hyderabadsys clarifying bugs and basic issues and advancement exercises with 24*7 specialized backings sevices.Hyderabadsys helps you to addition profundity learning on Selenium and it makes you prepared to turn into an ongoing Software Developers.
    Hyderabadsys online training give you complete freedom to learn anytime from anywhere. Selenium online training Provides quality online and interactive live video sessions. Hyderabadsys helps you to gain depth knowledge on Selenium and it makes you ready to become a real time Software Developers.

    ReplyDelete
  14. An error has occurred. See error log for more details.
    org/testng/remote/RemoteTestNG

    While creating testng run configuration

    ReplyDelete
  15. Please, let me know ,how we can enter password through AUTOIT, in case character are upper case, special characters
    Ex: Password9#

    ReplyDelete
  16. thanks for sharing very useful information for more training on selenium by industrial experts @MindMajix. You can attend free demo Here

    Check this site Mindmajix for indepth Selenium Training

    Go here if you’re looking for information on Selenium Training

    ReplyDelete
  17. Hi,
    awesome information shared on this blog thanks to shared the information
    sap sd training

    ReplyDelete
  18. Nice blog..very useful information is giving to us.specto Training offers Online training for sap scm MOdules
    sap mm training

    ReplyDelete
  19. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates…
    Regards Selenium training in chennai

    ReplyDelete
  20. Selenium Training in Hyderabad provided by Mr.Suresh Babu with 15+ years of Real-time Experience in Software Testing Services. We provide affordable Selenium training which aims to provide designed knowledge and skills to lead to become a successful Testing professional. QEdge Technologies was established by team of enthusiastic industry professionals from various organizations with the vision of providing world class quality education to fill the gap between industry requirement and learning. We have excellent experienced trainers who currently work on the technologies they teach.

    Course Curriculum of Selenium Training:
    Introduction
    Java Essentials for Selenium
    Java Programming Basics
    Object Oriented Programming in Java
    Exception Handling
    Automating Excel file Operations
    Automating Text File Operations
    Automating Database Operations
    Introduction to Selenium and its Components
    Selenium IDE
    WebDriver Introduction
    Launching AUT and Inspecting properties of Elements
    Automating Operations on various Elements
    Automating Keyboard and Mouse Events
    Handling multiple Windows
    Handling Alerts
    Handling Frames
    Handling Ajax Components
    Creating Customize XPath/CSS Selectors
    Synchronization
    TestNG
    What is TestNG?
    Automation Test Frameworks
    Page Object Model (POM) & Page Factory in Selenium
    Database Testing using Selenium
    AutoIT
    Selenium GRID
    MAVEN & JENKINS
    GIT
    LOG4J
    Project Testing WorkShop


    And More Sub topics
    For More Details please visit our Website
    Website: http://www.qedgetech.com/selenium-training
    Email: info@qedgetech.com
    Toll Free : 1800 300 73343

    ReplyDelete
  21. Informative post!!! Keep on Updating your information About Selenium At Intellipaat

    ReplyDelete
  22. I need a solution for the below scenario in Authentication popup.
    How to pass domain name in Username field using AutoIT.

    For ex: I would like to enter username as "domainname\username".

    It only sends domainname, doesntsends characters from "\"

    ReplyDelete
  23. Actually I need to handle two pop up's one after the other, the above code works for one pop up but it's not working for second.
    Thanks in advance:-)

    ReplyDelete
  24. Greetings Mate,

    Thanks for the tip, appreciate it. Your article definitely helped me to understand the core concepts.
    I’m most excited about the details your article touch based! I assume it doesn’t come out of the box, it sounds like you are saying we’d need to write in the handlers ourselves.
    Is there any other articles you would recommend to understand this better?


    Write the names
    of all the target files (which you have to generate anyway) to another target file. Then send away this list file either as an attachment or include it in the body of the email.
    Appreciate your effort for making such useful blogs and helping the community.
    Regards,
    Morgan

    ReplyDelete
  25. Very very nice Blog...my Friend Suggested me To go on through this blog...Quite interesting And maintaing A decent look Any Way can please Provide me Selenium RC Tutorials In your Upcoming posts

    ReplyDelete
  26. Hi There,


    Gratitude for putting up this prolific article! You truly make everything a cake walk. Genuinely good stuff, saving time and energy.

    I am newbie to Informatica, we have a requirement to Integrate to SFDC to SQL server using PowerCenter, for this I downloaded PowerCenter express Developer edition but couldn't see any provision for Salesforce say any connectors or Adaptors.
    I read Powerexchange is used to connect to SFDC and register as Salesforce objects and then plug-in needs to be installed in PCExpress then integration could happen.
    If anyone could provide the document or steps for this that would be really helpful.
    By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).
    Please keep providing such valuable information.


    Merci Beaucoup,
    Jonny

    ReplyDelete
  27. I am really happy with your blog because your article is very unique and powerful for new reader.
    Best selenium training Institute in chennai

    ReplyDelete
  28. Hello There,

    THANKS SO MUCH for sharing this! I would love to buy you a coffee since I now won’t be up all night that has been driving me crazy (until now!!). I just wish I knew what was going wrong but so glad it’s in the right place now! Thanks again:)

    The same case with the PUT API, while creating a PUT request we have to to provide PKEY_SRC_OBJECT (in case of update we can <a href="https://medium.com/@infamdm02/mdm-tutorial-b3d750f5df3d> provide value </a> for ROWID_OBJECT or for both). So, MDM will perform the check on PKEY_SRC_OBJECT, if it exits then update the record else will create a new record.
    I look forward to see your next updates.

    Obrigado,
    Abhiram

    ReplyDelete
  29. Hi There,

    Thank you. Absolutely perfect! I was SOOOOO excited after seeing the blog and these instructions were absolutely wonderful! You’re a life saver!



    do joiner with Source and your lookup tables. Informatica MDM Training USA
    That would be full outerjoin on your lookup table. Pass thru Expression put three condition for flags and then pass it thru router. Which wouuld routes your data depending upong filtering condition defined in Expression. And that would go to you Expression , where you can play with your date logic and it goes to Target tables. so there would be in total 4 target tables ex. for insert, delete, UPD as Indert and Update as update.

    Great effort, I wish I saw it earlier.

    Obrigado,
    Preethi.

    ReplyDelete
  30. Hi There,

    Great post. Can’t get any more straight forward than this article. Thanks!


    If you are talking about Database update statement on BO, it's a strict NO. The BO data have lots of associated data like XREF , History table which also needs to be updated along with the BO . Also the BO tables have fields like last updated date which needs to be updated when any field in the record changes . If you make a DB update on one field and miss out on any of the the rest, then the whole record will be corrupted.
    Informatica MDM Training


    Excellent tutorials - very easy to understand with all the details. I hope you will continue to provide more such tutorials.
    Kind Regards
    Irene Hynes

    ReplyDelete
  31. Thank You so much for writing this blog.Easy to understand and educate myself on Selenium and how the best way to go about it.Selenium IDE in an integrated development environment which tests code while integrating browser activity.If You Want More Details About Selenium Click here.

    ReplyDelete
  32. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa Training in Chennai

    rpa Training in bangalore

    rpa Training in pune

    blueprism Training in Chennai

    blueprism Training in bangalore

    blueprism Training in pune

    rpa online training

    ReplyDelete
  33. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.

    automation anywhere training in chennai

    automation anywhere training in bangalore

    automation anywhere training in pune

    automation anywhere online training

    blueprism online training

    rpa Training in sholinganallur

    rpa Training in annanagar

    ReplyDelete
  34. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    Digital Marketing Training in Chennai

    Digital Marketing Training in Bangalore

    digital marketing training in tambaram

    digital marketing training in annanagar

    ReplyDelete
  35. That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
    python training institute in chennai
    python training in Bangalore
    python training institute in chennai

    ReplyDelete
  36. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Blueprism training in Pune

    Blueprism online training

    Blue Prism Training in Pune

    ReplyDelete
  37. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
    python training in rajajinagar
    Python training in btm
    Python training in usa
    Python training in marathahalli

    ReplyDelete
  38. thanks for sharing very useful information for more training on selenium by industrial experts at SV Trainings . You can attend free demo Here

    Go here if you’re looking for information on Selenium Training

    ReplyDelete
  39. Thank you so much for a well written, easy to understand article on this. It can get really confusing when trying to explain it – but you did a great job. Thank you!

    angularjs Training

    in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  40. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    java training in omr | oracle training in chennai

    java training in annanagar | java training in chennai

    ReplyDelete

  41. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

    AWS Interview Questions And Answers

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    AWS Training in Pune | Best Amazon Web Services Training in Pune

    Amazon Web Services Training in Pune | Best AWS Training in Pune

    AWS Online Training | Online AWS Certification Course - Gangboard

    ReplyDelete
  42. I feel happy to find your post, excellent way of writing and also I would like to share with my colleagues so that they also get the opportunity to read such an informative blog.

    Selenium Training in Chennai
    Best selenium training in chennai
    iOS Training in Chennai
    Digital Marketing Training in Chennai
    Salesforce Training in Velachery
    Salesforce Training in Tambaram

    ReplyDelete
  43. Nice article. I was really impressed by seeing this article, it was very interesting and it is very useful for me.
    windows server online training

    windows server online training institute

    ReplyDelete
  44. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!
    online Python training
    python training in chennai

    ReplyDelete
  45. This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
    Data Science Training in Indira nagar
    Data Science Training in btm layout
    Python Training in Kalyan nagar
    Data Science training in Indira nagar
    Data Science Training in Marathahalli | Data Science training in Bangalore

    ReplyDelete
  46. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage
    contribution from other ones on this subject while our own child is truly discovering a great deal.
    Have fun with the remaining portion of the year.

    Selenium training in bangalore | best selenium training in bangalore | advanced selenium training in bangalore

    ReplyDelete
  47. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!
    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  48. This is quite educational arrange. It has famous breeding about what I rarity to vouch. Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved. This arrange is synchronous s informative impolites festivity to pity. I appreciated what you ok extremely here 

    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  49. Webroot is a security software which is universally famous for giving best quality protection services. At Webroot Support , you will get 24/7 assistance by qualified technicians.

    ReplyDelete
  50. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    Start your journey with RPA Course and get hands-on Experience with 100% Placement assistance from Expert Trainers with 8+ Years of experience @eTechno Soft Solutions Located in BTM Layout Bangalore.

    ReplyDelete
  51. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.

    digital marketing courses mumbai

    ReplyDelete
  52. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.thanks aa lo guys.
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  53. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!

    python Training in chennai

    python Course in chennai


    ReplyDelete
  54. People save their forefathers' customs, arts, depictions of their social lives, beliefs and ideals in any peaceful or warlike situation, or pleasures and sorrows in their folklore, which is considered a historical treasure.
    Or by conserving it via songs and poems, or by passing it down through folk dances.
    Qatar has a rich folk history that has been passed down from generation to generation.
    Al-Ardah:This traditional Qatari color is only worn by men at weddings.
    Al-Razif: All versions of Al-Razif are distinctively Qatari.
    It is performed by both young and old people dressed in traditional Qatari attire and wielding swords.

    ReplyDelete
  55. The Universal Currency Converter Is The Most Reliable And Accurate RMB TO USD Currency Conversion Tool On The Internet. It Is Fast And Easy To Use, And Supports Over 150 World Currencies.

    ReplyDelete
  56. XM REVIEW If You Are A Beginner, Check Out Our Guide On How To Open An Account With XM. They Offer Copy Trading Where You Can Copy The Trades Of Successful Traders.

    ReplyDelete
  57. Here Is A Review Of AVATRADE REVIEW . We Look At The History Of The Broker, Their Website, Platform, Trading Conditions, And Bonuses.

    ReplyDelete
  58. لیفت صورت، لیفتینگ یا rhytidectomy به روشی گفته می شود که برای جوان سازی دائمی پوست صورت انجام می شود.
    https://drkhaliliclinic.com/face-lift/
    جوان سازی پوست با عمل لیفت صورت

    ReplyDelete

  59. This piece of article is amazing. I would also like the world to know about a company which gives best quality logistics service ,ie is AFM Logistics Pvt Ltd is an international freight forwarding and customs clearing company established in Delhi. The company was constituted in 2012 and is indulged in providing complete logistics solution. The company has its own setup and wide network of agents throughout the world. International Logistics Companies In India . They are the best air cargo and ocean freight forwarding company in Delhi, India. AFM Logistics Pvt Ltd has been working as Import and Export Agent in India since 2012. They have been providing personal baggage shipping services in India for a very long time.

    ReplyDelete
  60. One of the best locations to locate a quality online course in
    Digital Marketing Course in Delhi to take is Digi uprise. They offer a selection of digital marketing classes intended for beginners, with subjects ranging from search engine optimization through to Google AdWords. They also offer a range of other helpful digital marketing courses, such as ones specially designed for more experienced users. They offer a digital marketing certificate program that is a highly sought-after skill for many companies and universities. It's a great opportunity to increase your digital marketing skill set and build an impressive resume.

    ReplyDelete
  61. Great post. keep sharing such a worthy information.
    jewellery erp software
    Jewellery erp software

    ReplyDelete
  62. Great post. keep sharing such a worthy information.
    Jewellery ERP Software UAE
    Jewellery ERP Software UAE

    ReplyDelete
  63. Hello, I must say it was a very helpful blog post. Very Informative and interesting as well, I am looking forward to reading more. Thanks for sharing.

    If you’ve been entrusted with a IELTS Coaching In Delhi and are looking for information, come here. They’ll consult with you and help you figure out what you need to know.

    ReplyDelete
  64. I'm glad to report that reading the post was interesting. Your article provided new information to me. You are performing admirably.
    Web Designing Course In Hyderabad

    ReplyDelete
  65. Awesome information shared on this blog thanks to shared the information.
    Python fullstack course in hyderabad

    ReplyDelete