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
已提問 2 年前檢視次數 101 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南