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
gefragt vor 2 Jahren101 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen