Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
622 views
in Selenium by
i am using this url  "http://www.dhtmlgoodies.com/submitted-scripts/i-google-like-drag-drop/index.html", apart form that url i need to perform on block 3,it should be moved  below block4.i had writeen the script but it is not working properly  could you please update me as early as possible where i need to change.
 
 
package practise;
 
import java.util.concurrent.TimeUnit;
 
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
 
public class Draganddrop {
public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(url);
WebElement src=driver.findElement(By.xpath("//div/div[@id='column-3']"));//div[@id='column-3']
WebElement dest=driver.findElement(By.xpath("//h1[text()='Block 3']"));
Actions act=new Actions(driver);
//act.dragAndDrop(src, dest).perform();
act.moveToElement(src).clickAndHold().moveToElement(dest).release().build().perform();
}
 
Thanks,
Anand.

 

1 Answer

0 like 0 dislike
by
selected by
 
Best answer

I guess swaping elements should work for you. It should be.

WebElement src=driver.findElement(By.xpath("//h1[text()='Block 3']"));

WebElement dest=driver.findElement(By.xpath("//div/div[@id='column-3']"));
 
Let me know how it goes.
by
moved by
now it is being worked successfully thank you so much to given correct answer
by
Welcome! I am glad it worked for you. Feel free to drop more questions here.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...