Skip to content
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

Update appium client 9 0 0 #5246

Merged
merged 39 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8e26f83
Update appium java-client to 9 version (appmanger is still needed to …
pnatashap Dec 4, 2023
03a7114
Update appium java-client to 9 version
pnatashap Dec 4, 2023
e6bd371
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 7, 2023
cc54018
Update versions for mobile
pnatashap Dec 10, 2023
433f448
Update webdrivermanager
pnatashap Dec 10, 2023
8d7ceef
Revert webdrivermanager
pnatashap Dec 13, 2023
fdbb9c3
Change all locators to AppiumBy.* variant. According to migration gui…
pnatashap Dec 15, 2023
878467a
Update selenium version to the latest one (Selenium versions below 4.…
pnatashap Dec 15, 2023
e5d0006
Remove unused imports
pnatashap Dec 15, 2023
146a8b2
Add checkstyle
pnatashap Dec 15, 2023
e39b8b4
Clean imports
pnatashap Dec 15, 2023
ed3c4f2
Fix style
pnatashap Dec 15, 2023
2dd5bef
Fix style
pnatashap Dec 15, 2023
da71889
Fix style
pnatashap Dec 15, 2023
d457c33
Fix style
pnatashap Dec 15, 2023
c1d5e4b
Fix style
pnatashap Dec 15, 2023
2a1254a
Fix style
pnatashap Dec 15, 2023
ea7a19d
Fix style
pnatashap Dec 15, 2023
706e87e
Fix style
pnatashap Dec 15, 2023
412fb74
Fix style
pnatashap Dec 15, 2023
9164d5f
Fix style
pnatashap Dec 15, 2023
85bd23f
Fix style
pnatashap Dec 15, 2023
0f6f021
Fix style
pnatashap Dec 15, 2023
e6403b5
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 15, 2023
e591fe5
Update to the latest checkstyle
pnatashap Dec 15, 2023
26ba269
Fix command
pnatashap Dec 18, 2023
a5bc263
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 18, 2023
e4d1256
Fix for case indent
pnatashap Dec 18, 2023
1d68ed3
Merge remote-tracking branch 'origin/update_appium_client_9_0_0' into…
pnatashap Dec 18, 2023
bd17fbd
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 19, 2023
cedff6c
Fix style errors
pnatashap Dec 19, 2023
2aa94ee
Fix style errors
pnatashap Dec 19, 2023
34daf98
Fix style errors
pnatashap Dec 19, 2023
170b226
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 19, 2023
1d0442e
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 22, 2023
2307824
Add core() usage
pnatashap Dec 22, 2023
05c9e97
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 26, 2023
d2040e0
Sometimes test start in one thread and finished in another
pnatashap Dec 26, 2023
ec21b8e
Merge branch 'master' into update_appium_client_9_0_0
pnatashap Dec 29, 2023
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
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
<property name="id" value="FileLength_Error" />
</module>
<module name="LineLength">
<property name="severity" value="error" />
<property name="severity" value="warning" />
<property name="max" value="180" />
</module>
<module name="RegexpHeader">
Expand Down Expand Up @@ -335,7 +335,7 @@
</module>
<module name="RegexpSingleline">
<property name="severity" value="error" />
<property name="format" value="(?&lt;!\.)(css|hasClass|hasAttribute|attr|find|finds)\(" />
<property name="format" value="(?&lt;!\.)(css|hasClass|hasAttribute|attr|find|finds)\((?!@|\)|String)" />
<property name="message" value="core() should be used with these methods" />
<property name="id" value="CoreMethodsUnused_Error" />
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static DriverBase defaultSetup(SiteInfo info, DriverBase jdi) {
jdi.driverName = isBlank(info.driverName) ? DRIVER.name : info.driverName;
return jdi;
}

public static MapArray<String, AnnotationRule> JDI_ANNOTATIONS = map(
$("Root", aRule(Root.class, (e,a)-> e.base().locator.setRoot())),
$("Frame", aRule(Frame.class, (e,a)-> e.base().setFrames(getFrames(a)))),
Expand Down Expand Up @@ -165,13 +166,13 @@ public static DriverBase defaultSetup(SiteInfo info, DriverBase jdi) {
e.base().setLocator(findByToBy(uis[0]));
return;
}
if (any(uis, j -> j.group().equals("") || j.group().equals(TEST_GROUP)))
if (any(uis, j -> j.group().isEmpty() || j.group().equals(TEST_GROUP)))
e.base().setLocator(findByToBy(first(uis, j -> j.group().equals(TEST_GROUP))));
})),
$("FindBy UI", aRule(FindBy.class, (e,a,f)-> {
FindBy[] jfindbys = f.getAnnotationsByType(FindBy.class);
if (jfindbys.length > 0) {
FindBy findBy = first(jfindbys, j -> j.group().equals("") || j.group().equals(TEST_GROUP));
FindBy findBy = first(jfindbys, j -> j.group().isEmpty() || j.group().equals(TEST_GROUP));
if (findBy != null) {
e.base().setLocator(findByToBy(findBy));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public static BatteryInfo getBatteryInfo() {
} else if (driver instanceof AndroidDriver) {
return ((AndroidDriver) driver).getBatteryInfo();
} else {
throw runtimeException("This method is not supported by the driver. The driver needs to be the instance of either Ios or Android driver");
throw runtimeException(
"This method is not supported by the driver. The driver needs to be the instance of either Ios or Android driver");
}
}

Expand Down Expand Up @@ -97,12 +98,14 @@ public static void performTouchId(boolean match) {
}

public static void toggleTouchIDEnrollment(boolean enabled) {
executeDriverMethod(PerformsTouchID.class, (PerformsTouchID driver) -> driver.toggleTouchIDEnrollment(enabled));
executeDriverMethod(PerformsTouchID.class,
(PerformsTouchID driver) -> driver.toggleTouchIDEnrollment(enabled));
}

// the next methods are for Android only
public static void fingerPrint(int fingerPrintId) {
executeDriverMethod(AuthenticatesByFinger.class, (AuthenticatesByFinger driver) -> driver.fingerPrint(fingerPrintId));
executeDriverMethod(AuthenticatesByFinger.class,
(AuthenticatesByFinger driver) -> driver.fingerPrint(fingerPrintId));
}

// this method is for Android only
Expand All @@ -117,11 +120,13 @@ public static String getClipBoardText() {
}

public static List<String> getPerformanceDataTypes() {
return executeDriverMethod(HasSupportedPerformanceDataType.class, HasSupportedPerformanceDataType::getSupportedPerformanceDataTypes);
return executeDriverMethod(HasSupportedPerformanceDataType.class,
HasSupportedPerformanceDataType::getSupportedPerformanceDataTypes);
}

public static List<List<Object>> getPerformanceData(String packageName, String dataType, int dataReadTimeout) {
return executeDriverMethod(HasSupportedPerformanceDataType.class, (HasSupportedPerformanceDataType driver) -> driver.getPerformanceData(packageName, dataType, dataReadTimeout));
return executeDriverMethod(HasSupportedPerformanceDataType.class,
(HasSupportedPerformanceDataType driver) -> driver.getPerformanceData(packageName, dataType, dataReadTimeout));
}

public static void sendSMS(String phoneNumber, String smsText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public class InfoButton extends Button {
public void openDetails() {
core().tap();
}
}
}
2 changes: 1 addition & 1 deletion jdi-light-mobile-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## How to launch web tests on Android emulator

Stable environment: Java 8, Maven 3.6.3, JDI-Light 1.3.23, TestNG 6.14.3, Aspectj 1.9.*, Appium 1.20.2, Android 10 <br/>
Stable environment: Java 11, Maven 3.6.+, JDI-Light 1.5.2+, TestNG 7.8.+, Aspectj 1.9.20, Appium 1.20.2+, Android 10 <br/>

1. Launch Android emulator and wait until home screen is ready.
1. Launch Appium and find out the listening URL in the console (usually http://0.0.0.0:4723)
Expand Down
17 changes: 17 additions & 0 deletions jdi-light-mobile-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@
<artifactId>allure-maven</artifactId>
<version>${allure.maven}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<configLocation>../config/checkstyle/checkstyle.xml</configLocation>
<propertyExpansion>samedir=${project.basedir}/../config/checkstyle</propertyExpansion>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ public class NotifyPage {
@MobileFindBy(xpath = "//*[@resource-id='com.android.systemui:id/notification_stack_scroller']/android.widget.FrameLayout[1]//*[@resource-id='android:id/time']")
public static Text timeStamp;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "//android.widget.Switch[@content-desc=\"Wi-Fi,Wifi signal full.,AndroidWifi\"]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ImageView")
public static Button wifiIcon;
//CHECKSTYLE:ON

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "//android.widget.Switch[@content-desc=\"Airplane mode\"]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageView")
public static Button airplaneModeIcon;
//CHECKSTYLE:ON

@MobileFindBy(xpath = "//*[@resource-id='android:id/message_name']")
public static MobileWebList messageNames;

@MobileFindBy(xpath = "//*[@resource-id='android:id/message_text']")
public static MobileWebList messageTexts;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class SpinnerPage {
@MobileFindBy(id = "spinner2")
public static Spinner planetSpinner;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ public class StatusBarPage {
@MobileFindBy(id = "com.android.systemui:id/no_notifications")
public static StatusBar noNotifications;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ScrollView/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.TextView")
public static StatusBar appName;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ScrollView/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageView")
public static StatusBar appIcon;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ScrollView/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView")
public static StatusBar title;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ScrollView/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView")
public static StatusBar appText;
//CHECKSTYLE:ON

@MobileFindBy(xpath = "//android.widget.Button[@content-desc='Clear notification']")
public static Button clearAllButton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ public class GalleryPage {
@MobileFindBy(accessibilityId = "1. Photos")
public static Button photos;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.Gallery/android.widget.ImageView[1]")
public static Button photoOne;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.Gallery/android.widget.ImageView[2]")
public static Button photoTwo;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.Gallery/android.widget.ImageView[3]")
public static Button photoThree;
//CHECKSTYLE:ON

@MobileFindBy(id = "io.appium.android.apis:id/layout2")
public static UIElement galleryLayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ public class PopupPage {
@MobileFindBy(accessibilityId = "Make a Popup!")
public static Button makePopupButton;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView")
public static Button searchItem;

//CHECKSTYLE:OFF
@MobileFindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView")
public static Button addItem;
//CHECKSTYLE:ON

@MobileFindBy(id = "android:id/submenuarrow")
public static Menu editItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public class TabsPage {
@MobileFindBy(id = "android:id/tabs")
public static TabBar tabBar;

//CHECKSTYLE:OFF
@MobileFindBy(xpath =
"/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.TabHost/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.TextView")
public static TabBar tabContent;
//CHECKSTYLE:ON

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.epam.jdi.light.mobile.elements.pageobjects.annotations.MobileFindBy;

public class EspressoAppPage {


@MobileFindBy(androidDataMatcher = "{\n" +
" \"name\": \"hasEntry\",\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

public class CreateNewContact {

//CHECKSTYLE:OFF
@FindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText[1]")
private TextField name;

//CHECKSTYLE:OFF
@FindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText[2]")
private TextField lastName;

//CHECKSTYLE:OFF
@FindBy(xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[3]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Spinner")
private DataListOptions phoneType;
//CHECKSTYLE:ON

public void fillInNewContactInformation(String contactName, String contactLastName, int phoneTypeIdx) {
fillName(contactName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class LabelViewPage {
public static Label label2;

@MobileFindBy(accessibilityId = "Text1 under Label1")
public static Label text_under_label1;
public static Label textUnderLabel1;

@MobileFindBy(accessibilityId = "Text2 under Label2")
public static Label text_under_label2;
public static Label textUnderLabel2;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EmulatorPowerInit {
public void setUp() {
initMobile(AndroidEmulatorPower.class);
logger.toLog("Run Emulator Power Tests");
AppManager.launchApp();
AppManager.launchApp("com.google.android.apps.nexuslauncher");
}
@AfterClass(alwaysRun = true)
public void tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void setUp() {
}
@AfterMethod(alwaysRun = true)
public void resetApp() {
AppManager.resetApp();
AppManager.resetApp("epam.com.EpamIOSTestAPP");
}

@AfterClass(alwaysRun = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public void iosLabelsTest() {
@Test
public void iosTextUnderTheLabelsTest() {
menuLabelView.tap();
Assert.assertEquals(LabelViewPage.text_under_label1.getValue(),
Assert.assertEquals(LabelViewPage.textUnderLabel1.getValue(),
"Text1 under the label");
Assert.assertEquals(LabelViewPage.text_under_label2.getValue(),
Assert.assertEquals(LabelViewPage.textUnderLabel2.getValue(),
"Text2 under the label");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public void setUp() {
File file = new File(FILE_NAME);
String path = file.getAbsolutePath();
AppManager.installApp(path);
AppManager.launchApp();
AppManager.launchApp("io.appium.android.apis");
}

@AfterClass(alwaysRun = true)
public void tearDown() {
logger.toLog("tearDown Activity Tests");
AppManager.closeApp();
AppManager.closeApp("io.appium.android.apis");
AppManager.removeApp("io.appium.android.apis");
WebDriverFactory.quit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public void setUp() {
File file = new File(FILE_NAME);
String path = file.getAbsolutePath();
AppManager.installApp(path);
AppManager.launchApp();
AppManager.launchApp("io.appium.android.apis");
}

@AfterMethod(alwaysRun = true)
public void resetApp() {
AppManager.resetApp();
AppManager.resetApp("io.appium.android.apis");
}

@AfterClass(alwaysRun = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void setUp() {

@BeforeMethod(alwaysRun = true)
public void createFile() {
AppManager.launchApp();
AppManager.launchApp("com.android.documentsui");
createdFile = new File(PATH_TO_FILE_LOCAL);
try {
createdFile.createNewFile();
Expand All @@ -53,7 +53,7 @@ public void createFile() {

@AfterMethod(alwaysRun = true)
public void resetApp() {
AppManager.resetApp();
AppManager.resetApp("com.android.documentsui");
deleteFileOnAndroid();
deleteFileIfExist(createdFile);
deleteFileIfExist(pulledFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class SettingsAppTestsInit {
public void setUp() {
initMobile(SettingsApp.class);
logger.toLog("Run Settings App Tests");
AppManager.launchApp();
AppManager.launchApp("com.android.settings");
}

@AfterMethod(alwaysRun = true)
public void resetApp() {
AppManager.resetApp();
AppManager.resetApp("com.android.settings");
}

@AfterClass(alwaysRun = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nativeapp_android.tests;

import com.epam.jdi.light.mobile.elements.composite.MobileScreen;
import io.appium.java_client.AppiumBy;
import nativeapp.android.apidemos.IndexPage;
import nativeapp.android.apidemos.views.PopupPage;
import nativeapp_android.ApiDemosTestInit;
Expand All @@ -22,28 +23,28 @@ public void init() {
public void isPopupDisplayedFromSearchItem() {
PopupPage.makePopupButton.click();
PopupPage.searchItem.tap();
PopupPage.screen.find(By.linkText("Clicked popup menu item Search")).isExist();
PopupPage.screen.find(AppiumBy.linkText("Clicked popup menu item Search")).isExist();
}

@Test
public void isPopupDisplayedFromAddItem() {
PopupPage.makePopupButton.click();
PopupPage.addItem.tap();
PopupPage.screen.find(By.linkText("Clicked popup menu item Add")).isExist();
PopupPage.screen.find(AppiumBy.linkText("Clicked popup menu item Add")).isExist();
}

@Test
public void isPopupDisplayedFromEditItem() {
PopupPage.makePopupButton.click();
PopupPage.editItem.tap();
PopupPage.screen.find(By.linkText("Clicked popup menu item Edit")).isExist();
PopupPage.screen.find(AppiumBy.linkText("Clicked popup menu item Edit")).isExist();
}

@Test
public void isPopupDisplayedFromShareItem() {
PopupPage.makePopupButton.click();
PopupPage.editItem.tap();
PopupPage.shareItem.tap();
PopupPage.screen.find(By.linkText("Clicked popup menu item Share")).isExist();
PopupPage.screen.find(AppiumBy.linkText("Clicked popup menu item Share")).isExist();
}
}
Loading
Loading