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회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠