Cloudwatch Canary: How to set User Agent for Python Selenium script?

2

According to this documentation I should be able to set the user agent of my CloudWatch Canary using:

add_user_agent(user_agent_str), ex: "synthetics_webdriver.add_user_agent('MyApp-1.0')"

I have tried this, and my code that attempts this looks like the following:

from aws_synthetics.selenium import synthetics_webdriver as webdriver
.
.
userAgentString = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36"
.
.
webdriver.add_user_agent(userAgentString)
driver = webdriver.Chrome()

The Canary passes the test, but the user agent is never set (it defaults to the standard user agent). Has anyone had any success changing the user agent for a Canary, and if so, how? Thank you!

  • Same problem here, one year afterwards. I have tried many things, including passing Options with a --user-agent argument to the Chrome object constructor, using an execute_step call wrapping my main function... to no avail. No matter what I do, debugging the user agent always gives me a CloudWatch string.

Hagsaws
asked 2 years ago98 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions