Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Selenium Webdriver pop up handling

33,379 views

Published on

Selenium Webdriver

Published in: Technology, Education
  • If you are looking for trusted essay writing service I highly recommend ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ The service I received was great. I got an A on my final paper which really helped my grade. Knowing that I can count on them in the future has really helped relieve the stress, anxiety and workload. I recommend everyone to give them a try. You'll be glad you did.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • If you are looking for trusted essay writing service I highly recommend ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ The service I received was great. I got an A on my final paper which really helped my grade. Knowing that I can count on them in the future has really helped relieve the stress, anxiety and workload. I recommend everyone to give them a try. You'll be glad you did.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • www.HelpWriting.net helped me too. I always order there
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • You can hardly find a student who enjoys writing a college papers. Among all the other tasks they get assigned in college, writing essays is one of the most difficult assignments. Fortunately for students, there are many offers nowadays which help to make this process easier. The best service which can help you is ⇒ www.HelpWriting.net ⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I'd advise you to use this service: ⇒ www.HelpWriting.net ⇐ The price of your order will depend on the deadline and type of paper (e.g. bachelor, undergraduate etc). The more time you have before the deadline - the less price of the order you will have. Thus, this service offers high-quality essays at the optimal price.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Selenium Webdriver pop up handling

  1. 1. PopUp handling in Selenium 2.x By Aparna Naik www.DestinationQA.com 1 www.destinationqa.com
  2. 2. AgendaDifferent types of PopUpsHandling JavaScript PopUpsWebdriver Alerts APIJava AWT Robot class to handle windows popupsOther ways to handle Popups 2 www.destinationqa.com
  3. 3. PopUpsUsually, a web application can generate following types of popup windows:JavaScript PopUps Browser PopUps Native OS PopUps JavaScript popup windows are generated by the web application code. Hence they can be controlled by the browser.Native Popups like the File Upload / Download windows call the operatingsystem’s native interface. Hence once they are opened, the browser has little control over them. 3 www.destinationqa.com
  4. 4. Handling JavaScript PopUpsSelenium provides an API to handleJavaScript PopUps. Alert alert = driver.switchTo().alert();The Alert API allows various operationson the Alert object: accept(), dismiss(), getText(),sendKeys() 4 www.destinationqa.com
  5. 5. Handling Browser and Native OSPopUpsAs Selenium does not provide support tothese kind of Popups, we need toexplore other options. There are severalways to handle such popups like:• Setup Browser Profiles• Use Java.awt.Robot toolkit• Use external program like AutoIT 5 www.destinationqa.com
  6. 6. Setup Browser DefaultsA useful way to handle popups is to set theBrowser Defaults to disable popups whereverpossible. This can usually be done for popupswhich ask whether a File should bedownloaded. 6 www.destinationqa.com
  7. 7. Handling File Download windowsWhen a file is to be downloaded, browser willask you where the file is to be saved.Usually, this option can also be set to a defaultlocation to avoid this popup. 7 www.destinationqa.com
  8. 8. Setup a Browser Profile• Selenium opens up its own profile with default settings each time a driver is initialized. Hence the option settings will not persist.• To avoid this, we can set up a profile for Selenium to use, where these preferences are set as required.Selenium Code to Initialize Profile: ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles.getProfile("Selenium"); 8 www.destinationqa.com
  9. 9. The Java AWT Robot ClassThis class can generate native input events to the underlyingOS using the Keyboard and Mouse InterfacesMethods in this class can be effectively used to do the minimalinteraction with native popups occurring in Web Applications.Some of the useful API provided are: • keyPress(); • mousePress(); • Mousemove(); 9 www.destinationqa.com
  10. 10. The Java AWT Robot Class Contd..Although the Robot Class can be used to interactwith PopUps, there are some limitations like:• All interactions happen using either Keyboard events or screen coordinates.• Keyboard events handle 1 character at a time (no Strings)• Cannot capture object properties using this class. www.destinationqa.com 10
  11. 11. Using External Programs (AutoIT)AutoIT is a tool that can automate theWindows GUI.AutoIT generates an executable file thatcan be called from the Selenium script.AutoIT Code Example: WinWaitActive("Choose File to Upload") Send("D:test.jpeg") Send("{ENTER}") Download AutoIT at: http://www.autoitscript.com/site/autoit/downloads/ www.destinationqa.com 11
  12. 12. Thank You…Aparna NaikEmail: naik.aparna@destinationqa.comTel: +91 99233 50980 12 www.destinationqa.com

×