selenium

hi all, i am new to selenium, i am supposed to drag and drop an element (draggable element)and to be placed between two other elements(sortable elements). i tried the below code butĀ  it is not working .

1.

Actions act=new Actions(driver);

WebElement dragg =driver.findElement(By.xpath(“//li[text()=’DragĀ  down’]”));

WebElement drop=driver.findElement(By.xpath(“//li[text()=’Item 3′]”));

Point point = drop.getLocation();
int xcord = point.getX();
System.out.println(“Element’s Position from left side Is “+xcord +” pixels.”);
int ycord = point.getY();
System.out.println(“Element’s Position from top side Is “+ycord +” pixels.”);

act.dragAndDrop(dragg, xcord ,ycord ).build().perform();

 

2.

Actions act=new Actions(driver);
WebElement dragg =driver.findElement(By.xpath(“//li[text()=’Drag me down’]”));
WebElement drop=driver.findElement(By.xpath(“//li[text()=’Item 3′]”));
act.dragAndDrop(dragg, drop).build().perform();

 

 

in both the case my element is not dropped after item3 but instead it is dropping after item5(which is the last element.

 

my output:

————-

drop element

item1

item2

item3

item4

item5

drop element

expected output:

——————–

drop element

item1

item2

item3

drop element

item4

item5

kindly help me

 

Default Asked on January 25, 2018 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.