程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Robot Framework 使用空格调用 add_argument大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Robot Framework 使用空格调用 add_argument?

开发过程中遇到Robot Framework 使用空格调用 add_argument的问题如何解决?下面主要结合日常开发的经验,给出你关于Robot Framework 使用空格调用 add_argument的解决方法建议,希望对你解决Robot Framework 使用空格调用 add_argument有所启发或帮助;

为了设置机器人框架使用的浏览器的自定义用户代理,我找到了所有可以设置的地方:

User agent with spaces

但是 add_argument User 的值没有被转义,它在浏览器中添加了不需要的错误标签:

Robot Framework 使用空格调用 add_argument

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,请注明来意。
标签: