“选择文件"在“硒库"中在机器人框架中 [英] "Choose File" in "seleniumlibrary" in robotframework
本文介绍了“选择文件"在“硒库"中在机器人框架中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用附加屏幕的关键字选择文件"来浏览多个文件(一个接一个).
I'm trying to browse multiple files (one after the other ) using the keyword "Choose File" for the attached screen.
- 红色圆圈是浏览文件的网络元素(右上角).
- 页面代码以红色突出显示.
- 黑色圆圈中的 xpath(左下角),在搜索时会一个接一个地突出显示浏览文件的 Web 元素.
以下是我的步骤:
Scroll Element Into View xpath=//span[contains(@class,'filebrowse .click')]
Wait Until Element is visible xpath=//span[contains(@class,'filebrowse .click')]
Set Focus To Element xpath=//span[contains(@class,'filebrowse .click')]
Choose File xpath=//span[contains(@class,'filebrowse .click')] ${file_path}
我在执行上述步骤时遇到以下错误 - 选择文件":
I got the error below for the step above - "Choose File" :
WebDriverException: Message: unknown error: cannot focus element
(Session info: chrome=71.0.3578.98)
(Driver info: chromedriver=2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.10586 x86_64)
推荐答案
我使用了下面的代码并且工作正常.
I used the below code and worked fine.
使用的库:
Library pyautogui
Library ImageHorizonLibrary
代码示例:
Scroll Element Into View xpath=//div[1]/div[5]/a/span
Wait Until Element is visible xpath=//div[1]/div[5]/a/span
Set Focus To Element xpath=//div[1]/div[5]/a/span
Click Element xpath=//div[1]/div[5]/a/span
Sleep 5s
pyautogui.Typewrite file_name.jpg
pyautogui.Key Down 'enter'
ImageHorizonLibrary.Press Combination Key.enter
Sleep 15s
为此,我必须将文件file_name.jpg"保存在默认浏览文件夹中.通过示例代码运行确定了默认文件夹.
For this I had to keep the file "file_name.jpg" in a default browse folder. Identified the default folder through a sample code run.
这篇关于“选择文件"在“硒库"中在机器人框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文