为了设置机器人框架使用的浏览器的自定义用户代理,我发现了您可以这样设置的每个位置:
${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'这些都不管用..。
发布于 2021-02-02 09:27:18
我已经找到了问题的根源。
在深入研究我的问题时,我发现这个问题也正是我遇到的问题:add_argument for user agent cuts off at first space
我使用的是一个机器人框架的对接图像:https://github.com/ppodgorsek/docker-robot-framework
二进制启动程序bin/chromium-browser.sh包含未引用的bash位置参数运算符:
#!/bin/sh
exec /usr/lib/chromium/chrome-original --disable-gpu --no-sandbox $@用引用的位置参数运算符代替它可以解决这个问题,我可以设置受控浏览器的自定义用户代理。
#!/bin/sh
exec /usr/lib/chromium/chrome-original --disable-gpu --no-sandbox "$@"https://stackoverflow.com/questions/65995818
复制相似问题