ISTQB Certified Software Test Engineer

Friday, October 25, 2013

Seleniumr-Handling Unexpected Popups

Some times When we are doing automation using Selenium , sometimes unexpected popups/alert message will appear on the screen.An automation engineer doesn't have a code to handle this when it is unexpected (since it is inconsistent),this leads to script failure.
In Selenium there is way to handle these unexpected alert/popup messages in the following way.
When ever we have unexpected popup/alert appears in the application,it throws an unhandled alert exception and script will fail. So We have to handle this unhandled alert exception in our test method and then we need to switch to the original content.

Example:
@Test
public void googleTest(){
try{
driver.get("http://google.com");
driver.findElementById("q").sendkeys("selenium");
}
catch(UnHandledAlertException e){
driver.switchTo().alert().accept();
driver.switchTo().defaultContent();
}}


The above test method explains about handling unexpected popups.
When ever we have an UnHandlerdAlertException,catch that excption,switch to alert and accept that alert.
Then Switch to Default Content means the original Content.

15 comments:



  1. Well did here, a set of useful interview questions which looks really helpful a lot to learn about the subject and also during interviews. But now a days Manual testing is not so enough to get placed in MNC companies, hence here I like to share some the most trending area in software testing field, which is Selenium -- A Top trending automation testing tool. Learn more about Selenium here ==> Best Selenium Training Institute in Chennai
    FREE PDF download the course content ==>
    Selenium Training in Velachery

    ReplyDelete
  2. Thanks For Explaining In Detail for us.Thanks Very Remarkable!
    Selenium Online Training In Bangalore

    ReplyDelete
  3. The information which you have provided is very good. It is very useful who is looking for selenium Online Training Hyderabad

    ReplyDelete
  4. 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..

    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
  5. 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.
    Data Science with Python training in chenni
    Data Science training in chennai
    Data science training in velachery
    Data science training in tambaram
    Data Science training in OMR
    Data Science training in anna nagar
    Data Science training in chennai
    Data science training in Bangalore

    ReplyDelete
  6. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
    java training in chennai | java training in bangalore

    java online training | java training in pune

    java training in chennai | java training in bangalore

    ReplyDelete
  7. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    python training in tambaram
    python training in annanagar
    python training in OMR
    python training in chennai

    ReplyDelete
  8. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Devops training in velachery
    Devops training in annanagar
    Devops training in sholinganallur
    Devops training in tambaram

    ReplyDelete
  9. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    Blueprism training in Chennai

    Blueprism training in Bangalore

    Blueprism training in Pune

    ReplyDelete
  10. That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.

    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  11. I’m planning to start my blog soon, but I’m a little lost on everything. Would you suggest starting with a free platform like Word Press or go for a paid option? There are so many choices out there that I’m completely confused. Any suggestions? Thanks a lot.
    Best AWS Training in Marathahalli | AWS Training in Marathahalli
    Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
    AWS Training in Velachery | Best AWS Course in Velachery,Chennai
    Best AWS Training in Chennai | AWS Training Institutes |Chennai,Velachery

    ReplyDelete
  12. Were a gaggle of volunteers as well as starting off a brand new gumption within a community. Your blog furnished us precious details to be effective on. You've got completed any amazing work!

    python training in velachery | python training institute in chennai

    ReplyDelete