RobotFramework:SHIFT+ENTER 组合按键 SeleniumLibrary

Posted

技术标签:

【中文标题】RobotFramework:SHIFT+ENTER 组合按键 SeleniumLibrary【英文标题】:RobotFramework: SHIFT+ENTER Combination Press Keys SeleniumLibrary 【发布时间】:2021-07-18 05:04:35 【问题描述】:

当我执行 SHIFT ENTER 时,网页上有一个按钮被按下(我不能使用 Click Element,因为这是键盘功能键测试)。但是来自SeleniumLibrary (3.3.0)Press Keys 似乎不起作用,我的意思是按钮没有被按下。我尝试了以下组合键,似乎没有任何效果。

    Press Keys    $None   SHIFT+ENTER
    Press Keys    $None   SHIFT+RETURN
    Press Keys    $None   SHIFT    ENTER

这是日志跟踪

KEYWORD Selenium2Library . Press Keys $None, SHIFT+ENTER
Documentation:  
Simulates user pressing key(s) to an element or on the active browser.

Start / End / Elapsed:  20210424 09:07:57.794 / 20210424 09:07:57.846 / 00:00:00.052
09:07:57.794    TRACE   Arguments: [ None | 'SHIFT+ENTER' ] 
09:07:57.795    INFO    Sending key(s) (u'SHIFT+ENTER',) to page.   
09:07:57.795    INFO    Pressing special key SHIFT down.    
09:07:57.796    INFO    Pressing special key ENTER down.    
09:07:57.796    INFO    Releasing special key SHIFT.    
09:07:57.796    INFO    Releasing special key ENTER.    
09:07:57.796    DEBUG   POST http://127.0.0.1:56002/session/7fee5882a08a0a823f6619b52bb6ae7c/actions "actions": ["parameters": "pointerType": "mouse", "type": "pointer", "id": "mouse", "actions": ["duration": 0, "type": "pause", "duration": 0, "type": "pause", "duration": 0, "type": "pause", "duration": 0, "type": "pause"], "type": "key", "id": "key", "actions": ["type": "keyDown", "value": "\ue008", "type": "keyDown", "value": "\ue007", "type": "keyUp", "value": "\ue008", "type": "keyUp", "value": "\ue007"]]  
09:07:57.846    DEBUG   http://127.0.0.1:56002 "POST /session/7fee5882a08a0a823f6619b52bb6ae7c/actions HTTP/1.1" 200 14 
09:07:57.846    DEBUG   Finished Request    
09:07:57.846    TRACE   Return: None

我认为问题出在序列上。当我手动尝试相同的序列时,它不起作用

09:07:57.795    INFO    Pressing special key SHIFT down.    
09:07:57.796    INFO    Pressing special key ENTER down.    
09:07:57.796    INFO    Releasing special key SHIFT.    
09:07:57.796    INFO    Releasing special key ENTER.

应该是这样的,这样手动工作

09:07:57.795    INFO    Pressing special key SHIFT down.    
09:07:57.796    INFO    Pressing special key ENTER down.    
09:07:57.796    INFO    Releasing special key ENTER.
09:07:57.796    INFO    Releasing special key SHIFT.    

知道如何实现吗?

【问题讨论】:

【参考方案1】:

尝试定位 body 标签而不是 None

Press Keys    xpath://body   SHIFT+ENTER
Press Keys    xpath://body   SHIFT+RETURN

如果仍然失败,您将不得不使用其他一些库,例如 AutoIt 或 PyAutoGUI。

【讨论】:

以上是关于RobotFramework:SHIFT+ENTER 组合按键 SeleniumLibrary的主要内容,如果未能解决你的问题,请参考以下文章

RobotFramework+python

idea快捷键

使用 Shift + Enter 键运行函数

eclipse快捷键

Visual Studio 快捷键

IntelliJ快捷键记录