Handling the accept cookies message

Posted about 2 months ago by Jim

Post a topic
Un Answered
J
Jim Admin

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

Sorted by
T

TheBugScout posted 7 days 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.


  • This way, if the cookie appears, the verify step executes, and its conditional child step performs the click action.


  • If the cookie does not appear, the "verify cookie policy is visible" step will not pass; however, it will also not fail because of the "warn and continue with sub-step" setting applied to it. Instead of failing, this step will execute with a yellow warning flag. Since the "click Reject button" step is a child of the verify step, it would normally be a failing step when the cookie does not appear. However, due to the "warn and continue with sub-step" setting applied to the parent step, this setting also applies to the child step. As a result, the "click Reject button" step will also execute with a yellow warning flag instead of failing, and your test will complete with a passed status.


  • Note: If you set the Error Threshold as "Warn and continue", test will complete with Failed status.


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

F

FiniteAutomaton posted about 2 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

© Orasi Software, Inc. | All Rights Reserved.