【发布时间】:2021-11-05 06:32:06
【问题描述】:
我正在尝试使用自定义方法来右键单击机器人框架。我定义了以下类
from robot.api.deco import keyword
from selenium.webdriver import ActionChains
from SeleniumLibrary import SeleniumLibrary
class ExtendedSeleniumLibrary(SeleniumLibrary):
@keyword("Right Click")
def Right_Click(self, xpath):
driver = self._current_browser()
actionChains = ActionChains(driver)
element=driver.find_element_by_xpath(str(xpath))
actionChains.context_click(element).perform()
和测试用例:
*** Settings ***
Library SeleniumLibrary
Library ExtendedSeleniumLibrary.ExtendedSeleniumLibrary
Resource ./ProcessModeler.robot
Resource ../../../../Code/test.robot
*** Variables ***
${ADD_BUTTON} = //button[@menu="add-popupmenu"]
${CREATE_FOLDER} = //a[contains(@data-selected-option,"ADD_FOLDER")]
${FRAME} = //iframe[contains(@name,"processmodeler_")]
${FOLDER_TITLE} = //*[@id="name"]
${SAVE_FOLDER} = //button[@class="btn-modal btn-modal-primary hide-focus"]
${MAIN_FOLDER} = //span[text()=" AutomationTestFolder "]
*** Keywords ***
Folder tear down
navigate to process designer
wait until element is visible ${FRAME} 180s
select frame ${FRAME}
wait until element is visible xpath=//span[text()=" AutomationTestFolder "]
right click xpath=//span[text()=" AutomationTestFolder "]
当我尝试运行测试时,我收到错误 No keyword with name 'right click' found.
奇怪的是,看起来 PyCharm 找到了库并在编码时以预览的形式显示给我:
我很困惑。请帮忙
【问题讨论】:
-
我们无法使用您提供的代码重现此问题。您的测试用例文件没有测试用例,只有关键字。还有语法错误。此外,如果您的 minimal reproducible example 不需要任何其他并非重现问题所必需的库,这也会有所帮助。
标签: python pycharm automated-tests robotframework