Thursday, 15 August 2013

java - How to perform drag drop in selenium grid -


I successfully installed the Selenium grid but was not able to do drag drop operations in the Selenium grid. If I run the code in testng it is working as expected, it is failing for the grid. I am learning the Selenium grid unable to fix this issue,

Jar: Selenium -Sarver- standalone-2.45.0.jar

Code:

East> Public Sector DragdropElements {WebDriver Driver; String Noduckal; @BeforeTest throws public Zero DrawDrop () MalformedElexception {// driver = New FirefoxDriver (); System.setProperty ("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); NodeURL = "http: // localhost: 4444 / wd / hub"; Desired capabilities cap = new desired capabilities (); Cap.setBrowserName ("Firefox"); /// cap.setVersion ("31.0"); //cap.setPlatform (Platform.VISTA); Driver = new remote web device (new url (node), cap); Driver.get ("http://only-testing-blog.blogspot.in/2014/09/drag-and-drop.html"); } @Test Public Zero DragdropElements1 () throws interrupted expressions {WebElement DragFrom = driver.findElement (By.xpath ("// * [@ id = 'dragdiv']"))); WebElement DragTo = driver.findElement (By.xpath ("// * [@ id = 'dropdiv']")); Action Builder = New Action (Driver); Action Drag Andrad 3 = Builder. Drag Endrope (Dragfram, Dragato) .build (); DragAndDrop3.perform (); String Textcomputer = Driver.Fund Element (Byexpath ("// * [@ id = 'blog1'] / div [1] / div / div / div / div [1] / h3")). Getteext (); Println ("" + TextTocompare); Assert.assertEquals (textcomputer, "drag and drop"); Exception}:

java.lang.ClassCastException: org.openqa.selenium .remote.RemoteWebDriver can not be inserted on org.openqa.selenium.interactions.HasInputDevices on Org .openqa.selenium.interactions.Actions (Action.Java 41). On the Qa.DragdropElements.DragdropElements1 (DragdropElements.java 45) on the sun. Sun.reflect.NativeMethodAccessorImpl.invoke (unknown source) on Reflect.NativeMethodAccessorImpl.invoke0 (Basic method)

Try it and it can work

  Actions actionsBuilder = new action (driver); Builder.keyDown (key control). Click (elementName) .keyUp (Keys.CONTROL); Action Action = actionsBuilder.build (); Action.perform ();  

Not sure why drag and drop for you is not working If you are running multi thread in your nodes, then just try to walk with the tone thread. Along with this, it is worth mentioning your node OS information.


No comments:

Post a Comment