Unable to drag & drop | Selenium Forum
M
Posted on 19/09/2016
Issue details:" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Offset within element cannot be scrolled into view"

Note: No Iframes are used in this screen

In one of our project there is drag & drop scenario. Iam facing below issue when trying to drag & drop the image. can you please guide me in fixing this
[attachment=1:qv6wh1vt]drag&dropsite.png[/attachment:qv6wh1vt]
[attachment=0:qv6wh1vt]drag&drop.png[/attachment:qv6wh1vt]

M
Replied on 20/09/2016

[quote:341ya0qm] Offset within element cannot be scrolled into view[/quote:341ya0qm]

where do you want to scroll? is it on screen?


M
Replied on 20/09/2016

Vertical scroll is displayed outside the screen. Iam trying to drag image from right hand section to section that is in the middle
[attachment=0:1earkf2n]drag&dropscroll.png[/attachment:1earkf2n]

Responsive image

M
Replied on 20/09/2016

cannot do that first scroll the image into the view and then drag it.


M
Replied on 20/09/2016

That means it is not possible through selenium??

Note: we no need to scroll down before drag & drop. on page load, itself all images are visible.


M
Replied on 20/09/2016

[quote:2mf3ue3s]That means it is not possible through selenium??
[/quote:2mf3ue3s]

no, it is possible. just keep in mind that both drag and drop location should be visible on screen.


M
Replied on 21/09/2016

In this scenario, both drag and drop are visible in the screen without scrolling.

on page load itself, both drag and drop are visible


M
Replied on 21/09/2016

then it should work.

send the code i'll check.


M
Replied on 21/09/2016

As build is placed in our Internal server,URL cannot be accessed. Below is code:

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.interactions.Actions;

public class Drag_Drop_S2KGraphics {

public static void main(String[] args) throws InterruptedException {

FirefoxProfile prof = new FirefoxProfile();
prof.setEnableNativeEvents(true);
WebDriver d = new FirefoxDriver(prof);
d.manage().window().maximize();
d.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
d.navigate().to("http://172.16.33.121/S2kGraphics/Web/Aspx/Login.aspx");

d.findElement(By.xpath("//*[@id='txtUserName']")).sendKeys("admin");
d.findElement(By.xpath("//*[@id='txtPassword']")).sendKeys("password");
d.findElement(By.xpath("//*[@id='btnSignIn']")).click();

d.findElement(By.xpath("//*[@id='canvas']/div[1]/section/div/div[1]/div"));

WebElement a = d.findElement(By.xpath("//*[@id='grdBrandList']/tbody/tr[13]/td[1]"));

JavascriptExecutor JE = ((JavascriptExecutor) d);
JE.executeScript("arguments[0].scrollIntoView(true);", a);
a.click();

d.findElement(By.xpath("//*[@id='gvMyCampaign']/tbody/tr[2]/td[1]")).click();
d.findElement(By.xpath("//*[@id='btnEdit']")).click();
d.findElement(By.xpath("//*[@id='btnContinue']")).click();

WebElement drag = d.findElement(By.xpath("//*[@id='gallery']/li[4]/div[1]"));
WebElement drop = d.findElement(By.xpath("//*[@id='divStyle_1_Logo_1']"));

Actions act = new Actions(d);

act.dragAndDrop(drag, drop).build().perform();

}

}


M
Replied on 22/09/2016

[quote:11fghboj]URL cannot be accessed[/quote:11fghboj]

ok can you come on skype or team viewer?


M
Replied on 22/09/2016

can i join you on skype now??


M
Replied on 22/09/2016

lets do it tomorrow(23 sept) 12 noon IST