I have to right click on a particular portion of my web page.
There are a few svg elements in background layer at the part where i need to right click. These svg elements are in a different layer which is invisible. below is the html code
HTML code of visible part (highlighted div element in image with class value containing 'z-Timeline-TimelineTrack') is something like below (you can also see svg elements part in the below code) HTML code of visible part of webpage
As you see that there are many 'line' elements.. i need to perform a right click on a specified line.
I am able to locate a particular line element using below xpath
@FindBy(xpath ="//*[name()='svg']//*[name()='line'][5]")
public WebElement anyAgendaLine;
After searching over internet, i found that i can use JavascriptExecutor to click on any invisible elements. before finding this i tried using Actions to perform context menu click which gave below error
Caused by: org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Offset within element cannot be scrolled into view: (2.5, 0.5): [object SVGLineElement]
My code for context menu click is like:
public static void rightClickAndSelectMenuItem(WebElement objWebElement, WebElement menuItem){
Actions action=new Actions(Setup.driver);
action.contextClick(objWebElement).sendKeys(Keys.ARROW_DOWN).click(menuItem).build().perform();
}
After finding that context menu click doesn't work, i tried just to click on the 'line' element:
(JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", objAgendaPage.anyAgendaLine);
which gave below error
org.openqa.selenium.WebDriverException: arguments[0].click is not a function
So please help me out here. I am not even able to just perform a click on this invisible 'line' element. Actually i need to perform a right click.