Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.appium.java_client;

import org.openqa.selenium.WebDriverException;

public class IllegalCoordinatesException extends WebDriverException {
private static final long serialVersionUID = 1L;

public IllegalCoordinatesException(String message) {
super(message);
}

}
157 changes: 82 additions & 75 deletions src/main/java/io/appium/java_client/MobileElement.java
Original file line number Diff line number Diff line change
@@ -1,75 +1,82 @@
/*
+Copyright 2014 Appium contributors
+Copyright 2014 Software Freedom Conservancy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ */

package io.appium.java_client;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.FileDetector;
import org.openqa.selenium.remote.RemoteWebElement;

import java.util.List;

public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {

protected FileDetector fileDetector;

public List<WebElement> findElements(By by) {
return by.findElements(this);
}

public WebElement findElement(By by) {
return by.findElement(this);
}

public WebElement findElementByAccessibilityId(String using) {
return findElement("accessibility id", using);
}

public List<WebElement> findElementsByAccessibilityId(String using) {
return findElements("accessibility id", using);
}

public Point getCenter() {
Point upperLeft = this.getLocation();
Dimension dimensions = this.getSize();
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
}

@Override
public void pinch() {
((AppiumDriver) parent).pinch(this);
}

@Override
public void tap(int fingers, int duration) {
((AppiumDriver) parent).tap(fingers, this, duration);
}

@Override
public void zoom() {
((AppiumDriver) parent).zoom(this);
}


@Override
public void swipe(SwipeElementDirection direction, int duration) {
direction.swipe((AppiumDriver) parent, this, duration);
}
}
/*
+Copyright 2014 Appium contributors
+Copyright 2014 Software Freedom Conservancy
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ */

package io.appium.java_client;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.FileDetector;
import org.openqa.selenium.remote.RemoteWebElement;

import java.util.List;

public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {

protected FileDetector fileDetector;

public List<WebElement> findElements(By by) {
return by.findElements(this);
}

public WebElement findElement(By by) {
return by.findElement(this);
}

public WebElement findElementByAccessibilityId(String using) {
return findElement("accessibility id", using);
}

public List<WebElement> findElementsByAccessibilityId(String using) {
return findElements("accessibility id", using);
}

public Point getCenter() {
Point upperLeft = this.getLocation();
Dimension dimensions = this.getSize();
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
}

@Override
public void pinch() {
((AppiumDriver) parent).pinch(this);
}

@Override
public void tap(int fingers, int duration) {
((AppiumDriver) parent).tap(fingers, this, duration);
}

@Override
public void zoom() {
((AppiumDriver) parent).zoom(this);
}


@Override
public void swipe(SwipeElementDirection direction, int duration) {
direction.swipe((AppiumDriver) parent, this, 0, 0, duration);
}

@Override
public void swipe(SwipeElementDirection direction, int offsetFromStartBorder,
int offsetFromEndBorder, int duration) throws IllegalCoordinatesException {
direction.swipe((AppiumDriver) parent, this, offsetFromStartBorder,
offsetFromEndBorder, duration);
}
}
Loading