Skip to main content

Right click and select using Selenium

Steps:

1. Find element/location where you need to right click
2. Create action and do context-click
3. Trigger keyboard event using Robot to select the menu option and enter

Code:

WebElement ele = driver.findElement(By.xpath(xpathExpression));

Actions act = new Actions(driver);
act.moveToElement(ele).contextClick();
act.build().perform();

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyPress(KeyEvent.VK_ENTER);


** Like if This helps ..

Comments

Popular posts from this blog

Rational Functional Tester: Calling RFT scripts from using xml tags

Hello, This will help to call RFT scripts in xml, if anyone using 'ant' this will help them to embed code to invoke RFT scripts. <java classname="com.rational.test.ft.rational_ft" fork="true" maxmemory="1024m">         <classpath>         <fileset dir="C:\Program Files\IBM\SDP\FunctionalTester\bin\">         <include name="rational_ft.jar" />         </fileset>         </classpath>         <jvmarg line="-Drational_ft.install.dir=&quot;C:\Program Files\IBM\SDP\jdk_\jre\bin&quot;" />         <arg line="-rt.bring_up_logviewer false -datastore &quot;D:\RFT-Dev\Project&quot; -playback RFTTestSet5.testcase4.TestScript1" />         <arg line="-args -scriptArg ${scriptValue}" /> ...

Rational Functional Tester: Creating and Reading Datapool cell value in RFT

Hello, Hope this will help for my friends who is trying to use data pool for dynamic values.If you want to use any run time values in between scripts then you will be looking for the functions to read/write/create datapool cells dynamically. /************ Dp row count *************************/ IDatapoolIterator  ite; ite.dpCurrent().getEquivalenceClass().getRecordCount(); /***************** to set cell value **************/ IDatapoolIterator it; ((DatapoolCell) it.dpCurrent().getCell("RunTimeSheetForContainers")).setCellValue("Y"); /*********** to load CSV files (csv to Datapool)*******************************/ public IDatapoolIterator LoadCSV(String Sname)       {             File fname=getFileName(Sname);             IDatapool dp=DatapoolUtilities. loadCSV (fname, "," , true );  ...

Rational Functional Tester: Finding Table cell value using descriptive programming in RFT

Hello, We can use this code to get the cell value of a table object. ITestDataTable myTableData1 = (ITestDataTable) xmlPackContainerDetailsContain() .getTestData("contents"); QtytoPack = myTableData1.getCell(0, 5).toString(); Note: xmlPackContainerDetailsContain() is a recorded object, use find() function to find object if you don't want recorded object