Skip to content

Commit

Permalink
Add test for document.getElementFromPoint()
Browse files Browse the repository at this point in the history
  • Loading branch information
ui4j committed Jul 15, 2015
1 parent fdad275 commit f3efe1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ui4j-webkit/src/test/java/com/ui4j/test/ImageOffsetTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ui4j.test;

import java.util.List;
import java.util.Optional;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -17,13 +18,13 @@ public void test() {
BrowserEngine webkit = BrowserFactory.getWebKit();
String location = JSObjectTest.class.getResource("/ImageOffsetTest.html").toExternalForm();
try (Page page = webkit.navigate(location)) {
page.show();
List<Element> elements = page.getDocument().queryAll("img");
elements.forEach(e -> {
System.out.println(e.getAttribute("alt").get() + " offset: " + e.getOffset());
});
Element image2 = elements.get(1);
Assert.assertEquals(200, image2.getOffset().getLeft());
Assert.assertEquals(200, image2.getOffset().getTop());
Optional<Element> element = page.getDocument().getElementFromPoint(200, 200);
Assert.assertEquals("image 2", element.get().getAttribute("alt").get());
}
}
}

0 comments on commit f3efe1d

Please sign in to comment.