Last updated: May 15, 2019 13:53
Perfecto Visual Analysis is the perfect tool to identify and dismiss browser popups
Automating web apps includes dealing with various web browser features. This includes the browser prompting the user to agree to certain actions, for example to remember a password, or provide location information.
Firefox popup to share location information
The problem, for the automation script, with these popups is that they are not part of the web app page and therefore not accessible using the standard Selenium tools. Perfecto's visual analysis tools, tried and tested in the mobile devices arena, provide the extra support to deal directly with these popup areas.
Using OCR to Dismiss Popup
The following code snippet shows how to use the Perfecto text:select to identify and click the "Share Location" button on the popup shown above.
Some short notes about the code:
- We use the screen.top, screen.height, and screen.width parameters to limit the area of the screen searched. This makes the visual analysis operation quicker.
- Use the index parameter if the string that you are searching for appears multiple times on the screen and you need to identify (for example) the second or third appearance.
- The command throws an exception if the text is not found.
- The timeout parameter can be used to wait for the text to appear on the screen. Similar to wait functions in Selenium.
The full sample can be seen in the Perfecto CommunitySamples GitHub:https://github.com/PerfectoCode/Community-Samples/tree/master/DismissWebPopup