Skip to content

Improve test #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 12, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:

name: Appium Flutter Integration Driver
jobs:
Java_Test:
Java_Test_Android:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -61,15 +61,15 @@ jobs:
appium driver list
appium plugin list
adb logcat > ${{ github.workspace }}/appium-logs/flutter.txt &
./gradlew clean build
Platform=android APP_PATH=${{ env.APP_PATH }} ./gradlew clean build
# appium server -pa=/wd/hub & wait-on http://127.0.0.1:4723/wd/hub/status &&
- name: upload appium logs
if: always()
uses: actions/upload-artifact@v4
with:
name: appium-logs
path: ${{ github.workspace }}/flutter-by/java/build/reports
WDIO_Test:
WDIO_Test_Android:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
45 changes: 33 additions & 12 deletions flutter-by/java/src/test/java/FlutterByTests.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.options.XCUITestOptions;
import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
import io.opentelemetry.api.baggage.BaggageBuilder;
import org.devicefarm.FlutterBy;
import org.devicefarm.FlutterCommands;
import org.devicefarm.models.*;
import org.junit.jupiter.api.*;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;


public class FlutterByTests {
private AndroidDriver driver;
private AppiumDriver driver;
protected static final int PORT = 4723;
private static final String USERNAME = "admin";
private static final String PASSWORD = "1234";
private static AppiumDriverLocalService service;
public void performLogin() {
WebElement userNameTxtField = driver.findElement(FlutterBy.key("username_text_field"));
WebElement passWordTxtField = driver.findElement(FlutterBy.key("password_text_field"));
WebElement loginButton = driver.findElement(FlutterBy.key("login_button"));
WebElement loginButton = driver.findElement(FlutterBy.key("LoginButton"));

userNameTxtField.clear();
userNameTxtField.sendKeys(USERNAME);
Expand All @@ -44,6 +51,7 @@ public static void beforeClass() {
service = new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(PORT)
.withLogFile(new File("appium.log"))
.withArgument(GeneralServerFlag.BASEPATH,"/wd/hub").build();
service.start();
}
Expand All @@ -56,11 +64,24 @@ public static void beforeClass() {

@BeforeEach
public void setUp() throws MalformedURLException {
UiAutomator2Options options = new UiAutomator2Options()
.setApp("https://github.com/AppiumTestDistribution/appium-flutter-server/releases/download/0.0.18/app-debug.apk")
.setAutomationName("FlutterIntegration");
if(System.getenv("Platform").equalsIgnoreCase("iOS")) {
XCUITestOptions options = new XCUITestOptions()
.setApp(System.getenv("APP_PATH"))
.setAutomationName("FlutterIntegration");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformName", "iOS");
desiredCapabilities.setCapability("automationName", "FlutterIntegration");
desiredCapabilities.setCapability("app", System.getenv("APP_PATH"));
desiredCapabilities.setCapability("flutterSystemPort", 31212);

driver = new IOSDriver(new URL("http://localhost:4723/wd/hub"), options);
} else {
UiAutomator2Options options = new UiAutomator2Options()
.setApp(System.getenv("APP_PATH"))
.setAutomationName("FlutterIntegration");
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), options);
}

driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), options);
}


Expand All @@ -75,7 +96,7 @@ public void tearDown() {
public void doubleTapTest() {
performLogin();
openScreen("Double Tap");
WebElement doubleTap = driver.findElement(FlutterBy.semanticsLabel("double_tap_button"))
WebElement doubleTap = driver.findElement(FlutterBy.key("double_tap_button"))
.findElement(FlutterBy.text("Double Tap"));

Assertions.assertEquals(doubleTap.getText(), "Double Tap");
Expand All @@ -97,8 +118,8 @@ public void doubleTapTest() {
public void waitTest() {
performLogin();
openScreen("Lazy Loading");
WebElement messageField = driver.findElement(FlutterBy.semanticsLabel("message_field"));
WebElement toggleButton = driver.findElement(FlutterBy.semanticsLabel("toggle_button"));
WebElement messageField = driver.findElement(FlutterBy.key("message_field"));
WebElement toggleButton = driver.findElement(FlutterBy.key("toggle_button"));

WaitForOptions waitOption = new WaitForOptions()
.setElement(messageField)
Expand All @@ -118,7 +139,7 @@ public void waitTest() {
public void longPressTest() {
performLogin();
openScreen("Long Press");
WebElement longPressButton = driver.findElement(FlutterBy.semanticsLabel("long_press_button"));
WebElement longPressButton = driver.findElement(FlutterBy.key("long_press_button"));
FlutterCommands.performLongPress(driver, new LongPressOptions().setElement(longPressButton));
Assertions.assertTrue(driver.findElement(FlutterBy.text("It was a long press")).isDisplayed());
}
Expand All @@ -127,8 +148,8 @@ public void longPressTest() {
public void dragAndDropTest() {
performLogin();
openScreen("Drag & Drop");
WebElement dragElement = driver.findElement(FlutterBy.semanticsLabel("drag_me"));
WebElement dropElement = driver.findElement(FlutterBy.semanticsLabel("drop_zone"));
WebElement dragElement = driver.findElement(FlutterBy.key("drag_me"));
WebElement dropElement = driver.findElement(FlutterBy.key("drop_zone"));
FlutterCommands.performDragAndDrop(driver, new DragAndDropOptions(dragElement, dropElement));
Assertions.assertTrue(driver.findElement(FlutterBy.text("The box is dropped")).isDisplayed());
}
Expand Down
21 changes: 21 additions & 0 deletions flutter-by/wdio-flutter-by-service/ios.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ts-nocheck
import { config as baseConfig } from './wdio.conf.ts';

export const config: WebdriverIO.Config = {
...baseConfig,
capabilities: [
{
// capabilities for local Appium web tests on an Android Emulator
platformName: 'iOS',
'appium:automationName': 'FlutterIntegration',
'appium:orientation': 'PORTRAIT',
'appium:udid': process.env.UDID,
'appium:app': process.env.APP_PATH,
'appium:newCommandTimeout': 240,
'appium:usePreinstalledWDA': true,
'appium:showIOSLog': true,
'appium:wdaLocalPort': 8456,
'appium:flutterServerLaunchTimeout': 25000,
},
],
};
Loading
Loading