Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Is there a a way to track Adobe Analytics events while using Selenium (with Python bindings)?

Avatar

Level 2

I'm creating automated tests, using Selenium and Python, and I need a way to check what events are being sent. So for instance, when a user is successfully logged in, an event is sent and I want to be able to quickly check that the event ID is correct without having to manually open the Adobe Experience Platform Debugger extension.

events.PNG

4 Replies

Avatar

Community Advisor

Hi,

 

I think an easy way to verify this is by examining the Adobe Datalayer object, which is populated in the Window object. This object will be filled with the events that are being triggered. You would need to collaborate with a developer or someone from analytics to confirm the event names you need to check.

EstebanBustamante_0-1692990357794.png

 



Esteban Bustamante

Avatar

Level 2

Thanks for the reply, Esteban. I can handle confirming the event names to check, but do you know how I can access the Adobe Datalayer object with an automated test with Python?

Avatar

Level 2

I solved this by using Selenium-wire. Then I have access to the requests.

 

    for request in driver.requests:  # Iterate through network requests
            query = request.querystring.replace('&', ' ')  # Replace ampersand with space
            query = query.split()  # Split on space into a list of requests
            for items in query:  # Iterate through items in query
                if "events" in items:  # If the word "events" is in an item
                    items = items.replace('%3D', '=')  # Replace unicode '=' with '='
                    items = items.replace('%2C', ' ')  # Replace unicode ',' with space
                    items = items.replace('%3A', ':')  # Replace unicode ':' with ':'
                    items = items.split()  # Split on space into a list of events
                    for e in items:  # Iterate through the list of events
                        if "events=" in e:  # Strip "events=" label
                            e = e.replace('events=', '')
                        event_list.append(e)  # Append the event to the event list