Selenium 如何在Robot框架中执行鼠标右键单击?

Selenium 如何在Robot框架中执行鼠标右键单击?,selenium,robotframework,Selenium,Robotframework,我正在用selenium编写自动测试。我需要在页面上的元素上单击鼠标右键,然后从上下文菜单中单击“选项” 是否有任何机器人框架库可能有助于做到这一点? 如果没有,你能帮助我如何用其他方式做到这一点,例如使用现有的关键字吗 我找到了解决办法。我为Selenium2库编写了一个扩展: from robot.api.deco import keyword from selenium import webdriver from selenium.webdriver import ActionChains

我正在用selenium编写自动测试。我需要在页面上的元素上单击鼠标右键,然后从上下文菜单中单击“选项”

是否有任何机器人框架库可能有助于做到这一点?
如果没有,你能帮助我如何用其他方式做到这一点,例如使用现有的关键字吗

我找到了解决办法。我为Selenium2库编写了一个扩展:

from robot.api.deco import keyword
from selenium import webdriver
from selenium.webdriver import ActionChains
from Selenium2Library import Selenium2Library

class ExtendedSeleniumLibrary(Selenium2Library):
    @keyword("Right Click Element")
    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()
现在,我不是在使用Selenium2库,而是在类中使用扩展的SeleniumLibrary和新方法,它可以正常工作

机器人技术:

WebElement SighnPad = (appium.findElement(By.id(Lib.getProperty(CONFIG_PATH, "Sighnparent"))).       //parent
                       findElement(By.className(Lib.getProperty(CONFIG_PATH, "sighnchild"))));  //child

SighnPad.click();

Robot rightclick = new Robot();

rightclick.delay(1500);

rightclick.mousePress(InputEvent.BUTTON1_DOWN_MASK);
rightclick.mouseMove(630, 420);
rightclick.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

我想您可以注入一些JS来调用右键单击?嗨,我在堆栈中找到了这个解决方案。[链接]我尝试了这个解决方案,但没有成功。你知道如何在js中做得更好吗?假设你正在起诉Selenium2Library,你试过关键词了吗?事实上,我找到了解决方案。我用新方法编写了Selenium2库的扩展。我发布了每个人的答案谁会有同样的问题me@BryanOakley“打开”上下文菜单是否适用于右键单击??