Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b6aa487
Splitting of TouchActions
SrinivasanTarget Aug 11, 2016
d76bad8
Codacy Fixes
SrinivasanTarget Aug 11, 2016
1909222
Merge branch 'master' of https://github.com/appium/java-client into T…
SrinivasanTarget Oct 30, 2016
b5bc4e6
Merge branch 'TouchActionSplitting' of https://github.com/SrinivasanT…
TikhomirovSergey Nov 3, 2016
ffbb4de
#456 FIX #454 FIX: API redesign.
TikhomirovSergey Nov 4, 2016
4ea6635
#456 FIX #454 FIX: MultiTouchAction refactoring
TikhomirovSergey Nov 6, 2016
34a718b
#456 FIX #454 FIX: New CreatesSwipeAction API
TikhomirovSergey Nov 8, 2016
e890280
#456 FIX #454 FIX:
TikhomirovSergey Nov 8, 2016
4b87991
#456 FIX #454 FIX: CreatesSwipeAction API was implemented
TikhomirovSergey Nov 9, 2016
f799d34
#456 FIX #454 FIX: AndroidTouchActions were covered with tests.
TikhomirovSergey Nov 10, 2016
f07ac6e
#456 FIX #454 FIX: Refactoring of MobileElement
TikhomirovSergey Nov 10, 2016
980b6a1
#456 FIX #454 FIX: IOSGesturesTest was redesigned.
TikhomirovSergey Nov 11, 2016
d832a19
#456 FIX #454 FIX: Checkstyle issues were got fixed
TikhomirovSergey Nov 11, 2016
f8ad455
#456 FIX #454 FIX: The additional test on Android.
TikhomirovSergey Nov 12, 2016
2ba3652
Issues that found by codecy were got fixed
TikhomirovSergey Nov 13, 2016
5b9a7c0
Merge branch 'SrinivasanTarget-TouchActionSplitting' of https://githu…
SrinivasanTarget Nov 14, 2016
f9a928e
The addition #513
SrinivasanTarget Nov 16, 2016
da9064b
Merge branch 'master' of https://github.com/appium/java-client into T…
SrinivasanTarget Nov 18, 2016
9ae8606
Added isKeyboardShown,getDisplayDensity and getSystemBars Commands
SrinivasanTarget Nov 19, 2016
d42df2b
Fixed Tests
SrinivasanTarget Nov 19, 2016
b63df4b
Merge branch 'TikhomirovSergey-SrinivasanTarget-TouchActionSplitting'…
SrinivasanTarget Nov 19, 2016
db74f17
Refractoring
SrinivasanTarget Nov 22, 2016
b2b5c14
Merge branch 'master' of https://github.com/appium/java-client into A…
SrinivasanTarget Nov 24, 2016
a3fdeda
Fixed styling issues
SrinivasanTarget Nov 24, 2016
20ba018
Fixed review comments
SrinivasanTarget Nov 25, 2016
358bdce
Fixed review comments
SrinivasanTarget Nov 25, 2016
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
The addition #513
Fixed Codacy errors Fixed Codacy errors
  • Loading branch information
SrinivasanTarget committed Nov 16, 2016
commit f9a928e48028a699bf4d00f452ace9ffd32b07da
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.appium.java_client.remote.IOSMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -41,7 +42,8 @@ public static void beforeClass() throws Exception {
service.start();

if (service == null || !service.isRunning()) {
throw new RuntimeException("An appium server node is not started!");
throw new AppiumServerHasNotBeenStartedLocallyException(
"An appium server node is not started!");
}

File appDir = new File("src/test/java/io/appium/java_client");
Expand Down
121 changes: 119 additions & 2 deletions src/test/java/io/appium/java_client/ios/IOSSwipeGestureTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,72 @@
package io.appium.java_client.ios;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import io.appium.java_client.MobileElement;
import io.appium.java_client.SwipeElementDirection;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.Point;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;

public class IOSSwipeGestureTest {

private static AppiumDriverLocalService service;
protected static IOSDriver<MobileElement> driver;

@BeforeClass
public static void beforeClass() throws Exception {
service = AppiumDriverLocalService.buildDefaultService();
service.start();

if (service == null || !service.isRunning()) {
throw new AppiumServerHasNotBeenStartedLocallyException(
"An appium server node is not started!");
}

File appDir = new File("src/test/java/io/appium/java_client");
File app = new File(appDir, "UICatalog.app.zip");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
//sometimes environment has performance problems
capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
driver = new IOSDriver<>(service.getUrl(), capabilities);
}

/**
* finishing.
*/
@AfterClass
public static void afterClass() {
if (driver != null) {
driver.quit();
}
if (service != null) {
service.stop();
}
}

@After public void afterMethod() {
driver.resetApp();
}

public class IOSSwipeGestureTest extends BaseIOSTest {
@Test
public void horizontalSwipingTest() {
MobileElement slider = driver.findElementByClassName("UIASlider");
driver.findElementByAccessibilityId("Sliders").click();
MobileElement slider = driver.findElementsByClassName("UIASlider").get(2);

IOSTouchAction touchAction = new IOSTouchAction(driver);
touchAction.swipe(slider, SwipeElementDirection.LEFT, slider.getSize().getWidth() / 2, 0, 3000);
Expand All @@ -19,4 +76,64 @@ public void horizontalSwipingTest() {
touchAction2.swipe(slider, SwipeElementDirection.RIGHT, 2, 0, 3000);
assertEquals("100%", slider.getAttribute("value"));
}

@Test
public void verticalSwipingTest() throws InterruptedException {
IOSElement tableView = (IOSElement) driver.findElementByClassName("UIATableView");
MobileElement element = driver.findElementByAccessibilityId("UIAStaticText");

String originalText = element.getText();

IOSTouchAction touchAction = new IOSTouchAction(driver);
touchAction.swipe(tableView, SwipeElementDirection.UP, 20, 15, 3000);
assertNotEquals(originalText, element.getText());

IOSTouchAction touchAction2 = new IOSTouchAction(driver);
touchAction2.swipe(tableView, SwipeElementDirection.DOWN, 20, 15, 3000);

Thread.sleep(5000);
assertEquals(originalText, element.getText());
}

@Test
public void swipeFromElementToElement() {
IOSElement e1 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Buttons");
IOSElement e2 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Sliders");

Point originalLocation = e2.getLocation();
IOSTouchAction touchAction = new IOSTouchAction(driver);
touchAction.swipe(e2, e1, 3000).perform();

Point newLocation = e2.getLocation();
assertNotEquals(originalLocation, newLocation);
}

@Test public void swipeFromCoordinatesToElement() {
IOSElement e1 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Buttons");
IOSElement e2 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Sliders");

Point originalLocation = e2.getLocation();
IOSTouchAction touchAction = new IOSTouchAction(driver);
touchAction.swipe(originalLocation.x + 50, originalLocation.y, e1, 3000).perform();

Point newLocation = e2.getLocation();
assertNotEquals(originalLocation, newLocation);
}

@Test public void whenSwipingIsCombinedWithOtherActions() {
IOSElement e1 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Buttons");
IOSElement e2 = (IOSElement) driver.findElementsByClassName("UIAWindow").get(1)
.findElementByAccessibilityId("Sliders");

IOSTouchAction touchAction = new IOSTouchAction(driver);
touchAction.swipe(e2, e1, 3000)
.tap(driver.findElementByAccessibilityId("Switches")).perform();

assertTrue(driver.findElementByAccessibilityId("TINTED").isDisplayed());
}
}