Skip to content

Commit 5dd07d1

Browse files
author
Alexey Makhov
committed
add scrollTo element
1 parent d4f5cf1 commit 5dd07d1

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1+
Avito patched Selendroid
2+
========================
3+
4+
Based on Selendroid 0.17.0. (`d4f5cf1`)
5+
6+
Changes
7+
-------
8+
9+
- Add scroll to element (`/wd/hub/session/:sessionId/element/:id/scrollTo`)
10+
11+
Build
12+
-----
13+
14+
```
15+
$ export MAVEN_OPTS="-Xms1024m -Xmx2048m -Xss2048k"
16+
$ mvn clean compile package
17+
```
18+
19+
120
Selendroid
221
==========
322

423
[![Build Status](https://travis-ci.org/selendroid/selendroid.png?branch=master)](https://travis-ci.org/selendroid/selendroid)
524

625
Selendroid is a test automation framework which drives of the UI of Android native and hybrid applications (apps) and the mobile web with Selendroid. Tests are written using the Selenium 2 client API and for testing the application under test must not be modified.
726

8-
Selendroid can be used on emulators and real devices and can be integrated as a node into the Selenium Grid for scaling and parallel testing.
27+
Selendroid can be used on emulators and real devices and can be integrated as a node into the Selenium Grid for scaling and parallel testing.
928

1029

1130
You want more details?

selendroid-server/src/main/java/io/selendroid/server/AndroidServlet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected void init() {
7171
register(getHandler, new GetElementAttribute(
7272
"/wd/hub/session/:sessionId/element/:id/attribute/:name"));
7373
register(postHandler, new ClearElement("/wd/hub/session/:sessionId/element/:id/clear"));
74+
register(postHandler, new ScrollToElement("/wd/hub/session/:sessionId/element/:id/scrollTo"));
7475
register(postHandler, new ClickElement("/wd/hub/session/:sessionId/element/:id/click"));
7576
register(getHandler,
7677
new GetElementDisplayed("/wd/hub/session/:sessionId/element/:id/displayed"));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.selendroid.server.handler;
2+
3+
import io.selendroid.server.common.Response;
4+
import io.selendroid.server.common.SelendroidResponse;
5+
import io.selendroid.server.common.http.HttpRequest;
6+
import io.selendroid.server.model.AndroidElement;
7+
import io.selendroid.server.util.SelendroidLogger;
8+
import org.json.JSONException;
9+
10+
public class ScrollToElement extends SafeRequestHandler {
11+
12+
public ScrollToElement(String mappedUri) {
13+
super(mappedUri);
14+
}
15+
16+
@Override
17+
public Response safeHandle(HttpRequest request) throws JSONException {
18+
SelendroidLogger.info("Scroll to element command");
19+
String id = getElementId(request);
20+
AndroidElement element = getElementFromCache(request, id);
21+
element.scrollTo();
22+
return new SelendroidResponse(getSessionId(request), "");
23+
}
24+
}

selendroid-server/src/main/java/io/selendroid/server/model/AndroidElement.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public interface AndroidElement {
3636

3737
public String getText();
3838

39+
public void scrollTo();
40+
3941
public void click();
4042

4143
public void submit();

selendroid-server/src/main/java/io/selendroid/server/model/AndroidNativeElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ public String getText() {
251251
return null;
252252
}
253253

254+
@Override
255+
public void scrollTo() {
256+
scrollIntoScreenIfNeeded();
257+
}
258+
254259
@Override
255260
public void click() {
256261
waitUntilIsDisplayed();

selendroid-server/src/main/java/io/selendroid/server/model/AndroidRElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public String getText() {
6262
throw new RuntimeException(NOT_IMPLEMENTED_ERROR_MSG);
6363
}
6464

65+
@Override
66+
public void scrollTo() {
67+
throw new RuntimeException(NOT_IMPLEMENTED_ERROR_MSG);
68+
}
69+
6570
@Override
6671
public void click() {
6772
throw new RuntimeException(NOT_IMPLEMENTED_ERROR_MSG);

selendroid-server/src/main/java/io/selendroid/server/model/AndroidWebElement.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ private Point getCenterCoordinates() {
235235
return new Point(topLeft.x + xSize / 2, topLeft.y+ ySize / 2);
236236
}
237237

238+
@Override
239+
public void scrollTo() {
240+
throw new RuntimeException("Not implemented yet");
241+
}
242+
238243
@Override
239244
public void click() {
240245
String tagName = getTagName();

0 commit comments

Comments
 (0)