首页 > 解决方案 > 无法在机器人框架中使用“选择文件”关键字上传图像文件。如何使用机器人框架处理图像上传验证?

问题描述

我正在尝试使用机器人框架验证我的应用程序的图像上传功能,我的脚本如下:

*** Variables ***
${browse}              xpath=//*[@id="file"]
${path_jpg}            ${EXECDIR}\\test_data\\Browse_Image\\apple.jpg
${path_png}            ${EXECDIR}\\test_data\\Browse_Image\\apple.png
${path_gif}            ${EXECDIR}\\test_data\\Browse_Image\\apple.gif
${path_webm}           ${EXECDIR}\\test_data\\Browse_Image\\apple.ppt

Choose File  ${browse}  ${path_jpg}

该脚本在 chrome 中运行良好,但在 firefox 和 edge 的情况下,会抛出如下错误消息:

火狐:

ElementNotInteractableException:消息:<input id="file" type="file">键盘无法访问元素**

边缘:

WebDriverException:消息:元素不可聚焦

如何处理?

标签: robotframework

解决方案


推荐阅读