18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
using Java, Drag and Drop operation is working properly.
Hi Pratyush,
with the following code, I am able to drag the element to the droppable element. However,it is witnessed that the element 'drag me' is dragged to the item4 but it is not picking up.
Could you please look into this and provide me with any suggestion to overcome this?
public static void main(String args[]) throws Exception{
setUp();
}
public static void setUp() {
String sahiBase = "C://sahi"; // where Sahi is installed or unzipped
String userDataDirectory = "C://sahi/userdata/bin";
Configuration.initJava(sahiBase, userDataDirectory); // Sets up configuration for proxy. Sets Controller to java mode.
Browser browser = new Browser("firefox");
browser.open();
browser.navigateTo("http://www.snook.ca/technical/mootoolsdragdrop/"
;
//browser.execute("_sahi._dragDrop(_sahi._div('Drag me'),_sahi._div('Item 2'))");
browser.dragDrop(browser.div("Drag me"),browser.div("Item 2"));
//browser.div("Drag me").mouseDown();
//browser.div("Item 4").mouseOver();
try {
browser.wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks,
Sai Pradeep.
with the following code, I am able to drag the element to the droppable element. However,it is witnessed that the element 'drag me' is dragged to the item4 but it is not picking up.
Could you please look into this and provide me with any suggestion to overcome this?
public static void main(String args[]) throws Exception{
setUp();
}
public static void setUp() {
String sahiBase = "C://sahi"; // where Sahi is installed or unzipped
String userDataDirectory = "C://sahi/userdata/bin";
Configuration.initJava(sahiBase, userDataDirectory); // Sets up configuration for proxy. Sets Controller to java mode.
Browser browser = new Browser("firefox");
browser.open();
browser.navigateTo("http://www.snook.ca/technical/mootoolsdragdrop/"
//browser.execute("_sahi._dragDrop(_sahi._div('Drag me'),_sahi._div('Item 2'))");
browser.dragDrop(browser.div("Drag me"),browser.div("Item 2"));
//browser.div("Drag me").mouseDown();
//browser.div("Item 4").mouseOver();
try {
browser.wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thanks,
Sai Pradeep.
Best Answer
-
Hi SaiPradeep,
Please try using the following piece of code:browser.div("Drag me").dragAndDropOn(browser.xy(browser.div("Item 2"), 5, 5));
Regards.
Answers
The difference between what you were trying earlier and the above code is that earlier we were dropping the element on the border of another element and now we are dropping it 5px inside (both x and y).
Regards.