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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<properties>
<cucumber.version>7.4.0</cucumber.version>
<selenium.version>4.2.2</selenium.version>
<selenium.version>4.3.0</selenium.version>
<appium.version>8.1.1</appium.version>
<testng.version>7.6.0</testng.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import lombok.experimental.UtilityClass;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WrapsDriver;
import org.openqa.selenium.support.events.EventFiringDecorator;
import org.openqa.selenium.support.events.WebDriverListener;

Expand Down Expand Up @@ -74,6 +75,12 @@ public static <D extends WebDriver> D getDriver() {
return (D) DRIVER_THREAD.get();
}

public static WebDriver getWrappedDriver() {
if (getDriver() instanceof WrapsDriver)
return ((WrapsDriver) getDriver()).getWrappedDriver();
return getDriver();
}

public static <D extends WebDriver> void setDriver(D driver) {
DRIVER_THREAD.set(driver);
STORED_DRIVER.putIfAbsent(driver.hashCode(), driver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,6 @@ public MobilePage enter(String accessibilityId, CharSequence text) {
return this;
}

public MobilePage tap(String accessibilityId) {
click(accessibilityId);
return this;
}

@Override
public MobilePage tap(By by) {
click(by);
return this;
}

@Override
public MobilePage doubleTap(By by) {
doubleClick(by);
return this;
}

public MobilePage swipe(String targetAccessibilityId, SwipeDirection swipeDirection) {
swipe(AppiumBy.accessibilityId(targetAccessibilityId), swipeDirection);
return this;
Expand Down
29 changes: 14 additions & 15 deletions selcukes-core/src/main/java/io/github/selcukes/core/page/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.github.selcukes.core.wait.WaitManager;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
Expand All @@ -48,6 +47,16 @@ default Page navigateTo(String url) {
return this;
}

default Page maximize() {
getDriver().manage().window().maximize();
return this;
}

default Page implicitlyWait() {
getDriver().manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
return this;
}

default String title() {
return getDriver().getTitle();
}
Expand Down Expand Up @@ -114,23 +123,13 @@ default Actions actions() {
return new Actions(getDriver());
}

default TouchActions touchActions() {
return new TouchActions(getDriver());
}

default Page tap(By by) {
touchActions().singleTap(find(by)).perform();
return this;
}

default Page doubleTap(By by) {
touchActions().doubleTap(find(by)).perform();
default Page dragAndDrop(WebElement source, WebElement target) {
actions().dragAndDrop(source, target).perform();
return this;
}

default Page swipe(By target) {
Point elementLocation = find(target).getLocation();
touchActions().scroll(elementLocation.getX(), elementLocation.getY()).perform();
default Page dragAndDrop(By source, By target) {
dragAndDrop(find(source, WaitCondition.VISIBLE), find(target, WaitCondition.VISIBLE));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.selcukes.core.enums.SwipeDirection;
import io.github.selcukes.core.page.MobilePage;
import io.github.selcukes.core.page.Pages;
import io.github.selcukes.core.wait.WaitCondition;
import org.openqa.selenium.By;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
Expand All @@ -41,43 +42,43 @@ void beforeTest() {

@Test(enabled = false)
public void expandAndScrollScreenTest() {
page.tap("Views")
.tap("Expandable Lists")
.tap("3. Simple Adapter")
page.click("Views")
.click("Expandable Lists")
.click("3. Simple Adapter")
.swipe(By.xpath("//android.widget.TextView[@text='Group 18']"), SwipeDirection.DOWN)
.tap(By.xpath("//android.widget.TextView[@text='Group 18']"))
.swipe(By.xpath("//android.widget.TextView[@text='Child 13']"), SwipeDirection.DOWN)
.click(By.xpath("//android.widget.TextView[@text='Group 18']"));
page.swipe(By.xpath("//android.widget.TextView[@text='Child 13']"), SwipeDirection.DOWN)
.swipe(By.xpath("//android.widget.TextView[@text='Group 1']"), SwipeDirection.UP);

}

@Test(enabled = false)
public void expandAndScrollElementTest() {
page.tap("Views")
page.click("Views")
.swipe("Splitting Touches across Views", SwipeDirection.DOWN)
.tap("Splitting Touches across Views")
.click("Splitting Touches across Views")
.swipe(By.id("io.appium.android.apis:id/list2"), By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Blue']"), SwipeDirection.DOWN)
.tap(By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Blue']"))
.swipe(By.id("io.appium.android.apis:id/list2"), By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Abbaye de Belloc']"), SwipeDirection.UP)
.tap(By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Abbaye de Belloc']"));
.click(By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Blue']"), WaitCondition.PRESENT);
page.swipe(By.id("io.appium.android.apis:id/list2"), By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Abbaye de Belloc']"), SwipeDirection.UP)
.click(By.xpath("//android.widget.ListView[2]/android.widget.TextView[@text='Abbaye de Belloc']"));
}

@Test(enabled = false)
public void alertTest() {
((AndroidDriver) DriverManager.getDriver())
((AndroidDriver) DriverManager.getWrappedDriver())
.startActivity(new Activity("io.appium.android.apis", ".app.AlertDialogSamples"));

page.tap(By.id("io.appium.android.apis:id/two_buttons"))
page.click(By.id("io.appium.android.apis:id/two_buttons"))

.tap(By.id("android:id/button1"));
.click(By.id("android:id/button1"));
}

@Test(enabled = false)
public void searchTest() {
((AndroidDriver) DriverManager.getDriver())
((AndroidDriver) DriverManager.getWrappedDriver())
.startActivity(new Activity("io.appium.android.apis", ".app.SearchInvoke"));
page.enter(By.id("txt_query_prefill"), "Hello world!")
.tap(By.id("btn_start_search"));
.click(By.id("btn_start_search"));
}

@AfterMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ public void shadowElementTest() {

}

@Test
public void dragAndDropTest() {
By source = By.xpath(".//*[@id='draggable']");
By target = By.xpath(".//*[@id='droppable']");
page.open("http://jqueryui.com/resources/demos/droppable/default.html")
.dragAndDrop(source, target)
.assertThat().element(target).textAs("Dropped!");

}

}