At times we have to right click on an object (Links, Table Contents etc.) to bring up its context menu from which we can select any one option. It seems very straight when we do the task manually, but simulating the mouse click through scripting is not as simple. The following example demonstrates how to do it. Suppose there is a link in a page named “Document”. By right clicking over the link we get a menu where we have an option “CreateDocument” to create a new document. Each option in the menu belongs to WebElement class. The code below helps us do it:
|
Set pathObj = Browser(“BrowserName”).Page(“Name”) // Assign the path to an object
getY = pathObj.Link(“Document”).GetROProperty(“abs_y”) // Get the Y-axis value of the link
deviceReplay.MouseClick getX,getY,RIGHT_MOUSE_BUTTON // Simulates the right click operation over the link
pathObj.WebElement(“name:=CreateDocument”).Click // Click on the “CreateDocument” option.
Set deviceReplay = Nothing |