【发布时间】:2021-05-05 19:31:20
【问题描述】:
为了设置机器人框架使用的浏览器的自定义用户代理,我找到了你可以这样设置的每个地方:
${options}= Evaluate
... sys.modules['selenium.webdriver'].ChromeOptions()
... sys, selenium.webdriver
Call Method ${options}
... add_argument --user-agent\=User agent with spaces
Create WebDriver Chrome chrome_options=${options}
Go To https://www.whatismybrowser.com/detect/what-is-my-user-agent
但是 add_argument User agent with spaces 的值没有被转义,它在浏览器中添加了不需要的错误标签:
whatismybrowser.com 检测到的用户代理是User。
我的问题很简单,如何传递有空格的参数值?
我试过了:
User agent with spacesUser\ agent\ with\ spacesUser\\ agent\\ with\\ spacesUser${SPACE}agent${SPACE}with${SPACE}spacesUser\${SPACE}agent\${SPACE}with\${SPACE}spaces"User agent with spaces"'User agent with spaces'
这些都不起作用...
【问题讨论】:
-
你可以试试三引号'''用户代理带空格'''
标签: selenium-webdriver robotframework user-agent