0

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?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Jakub Nowacki
  • 121
  • 2
  • 11
  • i suppose you could inject some JS to invoke a right click? – Goralight Nov 08 '17 at 09:10
  • Hi, I looked for the solution and I found this on stack. [link]https://stackoverflow.com/questions/17092328/how-to-simulate-right-click-in-javascript I tried this solution but it didn't work. Do you have any idea how to do it better in js? – Jakub Nowacki Nov 08 '17 at 09:32
  • Assuming you're suing `Selenium2Library`, have you tried the keyword [Open context menu](http://robotframework.org/Selenium2Library/Selenium2Library.html#Open%20Context%20Menu)? – Bryan Oakley Nov 08 '17 at 12:52
  • Actually, I found the solution. I wrote an extension to the Selenium2Library with new method. I posted the answer for everybody who would have the same problem as me – Jakub Nowacki Nov 08 '17 at 13:06
  • @BryanOakley is Open Context menu works for right click?? – indrajit narvekar Feb 16 '19 at 16:19

3 Answers3

0

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.

Jakub Nowacki
  • 121
  • 2
  • 11
0

Open Context Menu keyword from SeleniumLibrary.

Darius
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 10 '21 at 16:25
-1

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);
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Rohit Raj
  • 9
  • 2