Your Privacy
We use cookies to give you a better experience in Alchemy Help Center
You can learn more about what kind of cookies we use, why, and how from our Privacy Policy. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings in our cookie banner to change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer. For more details, check out our Privacy Policy link below.
View Privacy Policy
Strictly Necessary Cookies
These cookies are necessary for the website to function and cannot be switched off in our systems, but do not store any person information. They are usually set in response to your actions that triggers a request for services, such as setting your privacy preferences, logging in or filling forms. You can change your browser settings to alert you about these cookies, but some parts of the Website may not work.
View Cookies
The site am testing sometimes puts a message at the bottom of the screen asking me to accept or reject the cookie policy. It's not always there. When it does appear, I want my test to reject the cookies immediately. But, I don't want my test to fail looking for that message. How can I handle this?
1 Votes
2 Comments
TheBugScout posted 2 months ago
In Alchemy you can handle this scenario in two ways:
Approach 1: Configure your test with a conditional step that has "warn and continue" applied to the parent step.
First, record the step to check whether the cookie policy is visible or not. then record and set up a step to reject it.
You can follow the steps below to achieve this:
1. During recording, once the webpage loads properly and the cookie appears, right-click on the cookie policy. In the context menu that appears, choose the "Verify" option, and from the "Verify" sub-context menu, choose the "Visible" option. This action will record a step in your test to verify whether the cookie policy is visible.
2. Once the Verify step is recorded, click on the 'Reject' option. (This will record a step to click on the Reject button).
3. Next, select the 'click on Reject' button step by checking its checkbox and convert it into a conditional step.
4. Since the cookie does not always appear, the test may fail at the verify step if the cookie is not present. To handle this, click the eye icon to view the step details of the parent step, set the error threshold to "warn and continue with sub steps" and save the test.
Approach 2: Using an Error Handler Function.
This approach is preferred to handle the cookies which blocks the interactions with webpage.
Steps to achieve this:
1. Start recording the test. If a dynamic cookie appears, click the "Reject" button to record that action.
2. Continue recording the rest of your test steps as needed.
3. Select the step that handles the cookie (e.g., "Click Reject button") and convert it into a function. Name this function, for example, f1. (This creates a call step that references f1 in the test.)
4. Remove(delete) the call step that calls function f1 from the test.
5. To set the cookie-handling function as an error handler for the test, click the test information icon, find the error handler dropdown, and select the function f1. Then close the test information prompt and save the test.
Now, when you run the test, if a dynamic cookie appears and blocks interactions with the webpage, the error handler function will be activated to handle the cookie, preventing the test from failing.
Thanks!
1 Votes
FiniteAutomaton posted 4 months ago
If you record the action to reject the cookies, Alchemy will capture the information necessary to locate and perform the action.
Once you have recorded and saved your test, go to the step that performs that action, and click the eyeball thing out to the right of the step. You will probably want to reduce the amount of time in the "Wait for" box to something less than the default of 5 seconds. Depending on your application, you may know much faster if that message is present or not. There is no need to wait for a full 5 seconds every time the test runs.
You may also want to change the Error Threshold to "warn and continue" because if that cookies message doesn't appear, you probably dont want your test to fail.
0 Votes
Login or Sign up to post a comment