Handle Dynamic Popups
If your website has random popups like cookie consent, marketing, or advertisements causing test failures, you can automatically accept or reject them using the ai_config.json
file.
NOTE
ai_config.json
is located in the root of your project and allows you to configure the AI Test Engineer.
Steps to Handle Popups
Identify Unique Locators for the Popup
Find the unique locator for the popup. This can be a CSS, XPath, Role, or ID locator, but it must be unique to the popup.
Identify Unique Locators for the Action Button
Find the locator for the action button (e.g., the "Accept" button for a cookie consent popup or the close button for an advertisement).
Configure
popupHandlers
inai_config.json
Open your Project in VS Code and add a
popupHandlers
array in theai_config.json
file. The array contains objects withlocator.css
andclose_dialog_locator.css
for the popup and the action button.Example:
json{ "networkidle": false, "popupHandlers": [ { "locator": { "css": ".cookie-consent-popup" }, "close_dialog_locator": { "css": "//*[@id=\"cc-main\"]/div/div/div[2]/div[2]/div[1]/button[1]" } } ] }
WARNING
Make sure to escape any invalid characters like
"
in your CSS string.In this example, the
popupHandlers
array includes an object with the locator for the popup and the locator for the button that dismisses it.Test Locally
After making changes to the
ai_config.json
, run the test locally to ensure the popup is automatically dismissed during test runs, AI code generation, and in the Recorder.TIP
See Debugging Test Automation Code in VS Code for more information on using the VS Code debugger to test your code.
Upload Changes
Once the changes are working, upload the updated
ai_config.json
file back to your BlinqIO project. See Uploading the Modified Code for instructions.