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
feita há 2 anos101 visualizações
Sem respostas

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas