Jakub Nowacki
Jakub Nowacki

Reputation: 131

How to perform mouse right click in Robot Framework?

I' writing automated tests using selenium in RIDE. I need somehow to right click element on page and click option from context menu.

Is somewhere any library for Robot Framework which may be helpful to do that? If not, Could you help me how to do that in other way, using existing keywords for example?

Upvotes: 1

Views: 10949

Answers (3)

Darius
Darius

Reputation: 11

Open Context Menu keyword from SeleniumLibrary.

Upvotes: 1

Rohit Raj
Rohit Raj

Reputation: 9

Robot tec:

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);

Upvotes: -1

Jakub Nowacki
Jakub Nowacki

Reputation: 131

I found the solution. I wrote an extension to the Selenium2Library:

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()

Now, I'm not using Selenium2Library but my ExtendedSeleniumLibrary with new method in class and it works.

Upvotes: 0

Related Questions