Wer*_*Kop 3 python upload base64 robotframework docker
我正在尝试在 docker 容器中运行测试,该容器在本地运行没有问题:我想从“正确”目录上传正确的.csv 文件
*** Keyword ***
Upload file
[Arguments] ${directory} ${file}
Choose File ${choose_file_input} ${EXECDIR}/Files/${directory}/${file}
** Test case ***
Upload
Upload file correct correct.csv
Run Code Online (Sandbox Code Playgroud)
但是,当在 docker 中运行测试时,我收到 AttributeError: module 'base64' has no attribute 'encodestring' 的失败。是因为docker中没有GUI吗?或者需要修复编码?或者最终也许还有另一种解决方案可以用来上传文件?
15:20:01.250 INFO Sending /App/Files/correct/correct.csv to browser.
15:20:01.251 DEBUG POST http://192.168.1.29:4444/wd/hub/session/4b6d453b394adaaa51bb4149e9ba8678/elements {"using": "xpath", "value": "//div[@id=\"upload\"]//input"}
15:20:01.252 DEBUG Starting new HTTP connection (1): 192.168.1.29:4444
15:20:01.305 DEBUG http://192.168.1.29:4444 "POST /wd/hub/session/4b6d453b394adaaa51bb4149e9ba8678/elements HTTP/1.1" 200 90
15:20:01.305 DEBUG Finished Request
15:20:01.618 FAIL AttributeError: module 'base64' has no attribute 'encodestring'
15:20:01.619 DEBUG Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/SeleniumLibrary/__init__.py", line 490, in run_keyword
return DynamicCore.run_keyword(self, name, args, kwargs)
File "/usr/local/lib/python3.9/site-packages/robotlibcore.py", line 103, in run_keyword
return self.keywords[name](*args, **(kwargs or {}))
File "/usr/local/lib/python3.9/site-packages/SeleniumLibrary/keywords/formelement.py", line 224, in choose_file
self.find_element(locator).send_keys(file_path)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 475, in send_keys
value = self._upload(local_file)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 695, in _upload
content = base64.encodestring(fp.getvalue())
Run Code Online (Sandbox Code Playgroud)
小智 6
我们也遇到了这个问题,但由于与其他库不兼容,因此无法返回旧版本的 Python。如果您发现自己处于同一位置,可以重新创建别名,如下所示:
import base64
base64.encodestring = base64.encodebytes
Run Code Online (Sandbox Code Playgroud)
无论你的切入点是什么。
| 归档时间: |
|
| 查看次数: |
6796 次 |
| 最近记录: |