Skip to content

Commit

Permalink
Adds test case issue SeleniumHQ#4241
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-savchuk committed Sep 9, 2013
1 parent b90b631 commit 2d334bb
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
67 changes: 67 additions & 0 deletions common/src/web/dragAndDropInsideScrolledDiv.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<html>
<head>
<style>
<!--
.dragme{position:relative;}
-->
</style>
<script language="JavaScript1.2">
<!--

var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{

if (isdrag)
{
dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}

function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";

while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}

if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}

document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");

//-->
</script>

</head>
<body>
<div style="overflow: scroll; margin: 20px; height: 90%; width: 90%">
<div style="height: 4000px; width: 4000px;">
<div id="test1" class="dragme" style="width: 100px; height: 100px;
background-color: black;" />
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ public void testDragAndDropElementWithOffsetInIframeAtBottom() {
assertEquals(initial.moveBy(20, 20), img1.getLocation());
}

@JavascriptEnabled
@Ignore(value = {OPERA}, reason = "OPERA: ?")
@Test
public void testDragAndDropElementWithOffsetInScrolledDiv() {
assumeFalse("See issue 4241", Browser.detect() == Browser.ff &&
TestUtilities.isNativeEventsEnabled(driver));

driver.get(appServer.whereIs("dragAndDropInsideScrolledDiv.html"));

WebElement el = driver.findElement(By.id("test1"));
Point initial = el.getLocation();

new Actions(driver).dragAndDropBy(el, 3700, 3700).perform();

assertEquals(initial.moveBy(3700, 3700), el.getLocation());
}

@JavascriptEnabled
@Test
public void testElementInDiv() {
Expand Down

0 comments on commit 2d334bb

Please sign in to comment.