大佬教程收集整理的这篇文章主要介绍了Robot Framework 使用空格调用 add_argument,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
为了设置机器人框架使用的浏览器的自定义用户代理,我找到了所有可以设置的地方:
User agent with spaces
但是 add_argument User
的值没有被转义,它在浏览器中添加了不需要的错误标签:
whatismybrowser.com 检测到的用户代理是 User agent with spaces
。
我的问题很简单,如何传递带有空格的参数值?
我试过了:
User\ agent\ with\ spaces
User\\ agent\\ with\\ spaces
User${SPACE}agent${SPACE}with${SPACE}spaces
User\${SPACE}agent\${SPACE}with\${SPACE}spaces
"User agent with spaces"
'User agent with spaces'
from collections import Counter
data = [
{'br' : 'Kadek','mnt' : '2020-10','vl' : 30},{'br' : 'Kadek','vl' : 40},'vl' : 20},{'br' : 'Dede','mnt' : '2020-5',]
cnt = Counter()
for i in data:
cnt[i['br'],i['mnt']] += i['value']
result = ([{'br': k[0],'mnt': k[1],'value': v}
for k,v in cnt.items()])
print(result)
这些都不起作用...
我已经找到了问题的根本原因。
在深入了解我的问题时,我发现这个问题也正是我遇到的问题:add_argument for user agent cuts off at first space
我在这里使用了机器人框架 docker 镜像: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 "$@"
以上是大佬教程为你收集整理的Robot Framework 使用空格调用 add_argument全部内容,希望文章能够帮你解决Robot Framework 使用空格调用 add_argument所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。