Documentation - MaxGolden/MobileApp_MySprint_iOS GitHub Wiki
-
- Appium
-
- TestNG
-
- Device / Device Simulator
-
- ALLURE
-
- MAVEN
-
- IntelliJ IDEA
-
- GITHUB
-
- Jenkins
testng 6.14.3 (TestNG)
java-client 7.0.0 (Appium)
extentreports 2.41.2 (Extent)
allure-testng 2.12.0 (ALLURE)
log4j 1.2.17
slf4j-api 1.7.25
slf4j-simple 1.7.25
freemarker 2.3.28
zip4j 1.3.2
Project
- allure-results
- testng
- src – main – java
- Android_Base
- app
- Data
- Listeners
- Util
- SPRCOM_XXXXX
Android device simulator could be created by ANDROID STUDIO. (Video Attachment only support 28+ version of the android device system)
Download and install Xcode which includes the iOS device and versions of iOS.
Use Listeners can print info of test start, finish, pass and skip to let the tester know the status of the whole testing progress.
-
onStart
public void onStart(ITestContext iTestContext) {
System.out.println("LISTENER: onStart Test - " + iTestContext.getName());
}
When the test begin, the listener will print information.
-
onTestFailure
public void onTestFailure(ITestResult iTestResult)
{
ITestContext context = iTestResult.getTestContext();
System.out.println("LISTENER: Test failed ... " + iTestResult.getName() + " --- " + context) ;
}
Listener will print information when test failed.
The attachments can be shown in the result page
-
- Text attachment adding
@Attachment(value = "IMPORTANT Message", type = "text/plain")
public static String saveTextLog_Allure(String message) {
return message;
}
-
- Screenshot attachment adding
@Attachment(value = "Auto Screenshot", type = "image/png")
public static byte[] saveScreenshotPNG_Allure(IOSDriver driver) {
return ((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES);
}
-
- Video attachment adding
@Attachment(value = "Video Attachment", type = "video/mp4")
public static byte[] saveH264_Allure_Video(String videoClip) {
return Base64.decodeBase64(videoClip);
}
Put the files under the app
folder for using
Project - src - main - java - Util - iOS_Driver_Methods
Almost all the testing cases relate to the element finding and then do the tap, scroll, typing, etc.
Find element by using the element "accessibility ID" if it has.
-
1. Method -
findByAccessibilityID_Click
Click the element
Example:
findByAccessibilityID_Click(30, "Make a payment");
The code means it will take 30 seconds to find element with accessibility id of "Make a payment".
-
- Method -
findByAccessibilityID_SendKey
Type in the element, usually the element is text box or field
- Method -
Example:
findByAccessibilityID_SendKey(30, "ZIP", "66100");
The code means it will take 30 seconds to find element with accessibility id of "ZIP" and type in "66100".
-
- Method -
findByAccessibilityID_Clear
Clear the element
- Method -
Example:
findByAccessibilityID_Clear(10, "ZIP");
The code means it will take 10 seconds to find element with accessibility id of "ZIP" and empty the text field.
-
- Method -
findByAccessibilityID_GetText
Get text of the element
- Method -
Example:
findByAccessibilityID_GetText(10, "ZIP");
The code means it will take 10 seconds to find element with accessibility id of "ZIP" and get the content of the element.
-
- Method -
findByAccessibilityID_Enable
Check the status of element is enable(true) or disable(false)
- Method -
Example:
findByAccessibilityID_Enable(10, "Cancel");
The code means it will take 10 seconds to find element with accessibility id of "Cancel" and check the element status.
-
- Method -
findByAccessibilityID_Counts
Check how many elements with same accessibility id
- Method -
Example:
findByAccessibilityID_Counts(10, "Submit");
The code means it will take 10 seconds to find elements with accessibility id of "Cancel" and check the element amount.
-
- Method -
findByAccessibilityID_Exist
Check the element existence.
- Method -
Example:
findByAccessibilityID_Exist(10, "Submit");
The code means it will take 10 seconds to find element with accessibility id of "Cancel" and check the element existence.
Find element by using the element "type"
-
- Method -
findByClassType_Click
Click the element
- Method -
Example:
findByClassType_Click(10, "XCUIElementTypeButton");
The code means it will take 10 seconds to find and click element with type of "XCUIElementTypeButton".
-
- Method -
findByClassType_SendKey
Type in the element, usually the element is text box or field
- Method -
Example:
findByClassType_SendKey(10, "XCUIElementTypeOther", "113");
The code means it will take 10 seconds to find the element with type of "XCUIElementTypeButton" and type in "113".
-
- Method -
findByClassType_Clear
Clear the element
- Method -
Example:
findByClassType_Clear(10, "XCUIElementTypeOther");
The code means it will take 10 seconds to find the element with type of "XCUIElementTypeButton" and empty the text field
-
- Method -
findByClassType_Exist
Check the element existence.
- Method -
Example:
findByClassType_Exist(10, "XCUIElementTypeOther");
The code means it will take 10 seconds to find the element with type of "XCUIElementTypeButton" and check the element existence.
Find element by using the element "name"
-
- Method -
findByName_Click
Click the element
- Method -
Example:
findByName_Click(10, "make a payment");
The code means it will take 10 seconds to find and click the element with name of "make a payment".
-
- Method -
findByName_SendKey
Type in the element, usually the element is text box or field
- Method -
Example:
findByName_SendKey(10, "ZIP", "66100");
The code means it will take 10 seconds to find the element with name of "ZIP" and type in "66100".
-
- Method -
findByName_Clear
Clear the element
- Method -
Example:
findByName_Clear(10, "ZIP");
The code means it will take 10 seconds to find the element with name of "ZIP" and empty the text field.
-
- Method -
findByName_Exist
Check the element existence.
- Method -
Example:
findByName_Exist(10, "ZIP");
The code means it will take 10 seconds to find the element with name of "ZIP" and check the element existence
Find element by using the element "id"
-
- Method -
findByID_Click
Click the element
- Method -
Example:
findByID_Click(10, "OK");
The code means it will take 10 seconds to find and click the element with id of "OK".
-
- Method -
findByID_SendKeys
Type in the element, usually the element is text box or field
- Method -
Example:
findByID_SendKeys(10, "ZIP", "66100");
The code means it will take 10 seconds to find the element with id of "ZIP" and type in "66100".
-
- Method -
findByID_Exist
Check the element existence.
- Method -
Example:
findByID_Exist(10, "ZIP");
The code means it will take 10 seconds to find the element with id of "ZIP" and check the element existence.
Find element by using the element "Xpath"
-
- Method -
findByValueXpath_Click
Click the element
- Method -
Example:
findByValueXpath_Click(10, "//XCUIElementTypeButton[@text=\"Make a payment\"]");
The code means it will take 10 seconds to find and click the element with Xpath of "//XCUIElementTypeButton[@text="Make a payment"]".
-
- Method -
findByValueXpath_Exist
Check the element existence.
- Method -
Example:
findByValueXpath_Click(10, "//XCUIElementTypeButton[@text=\"Make a payment\"]");
The code means it will take 10 seconds to find the element with Xpath of "//XCUIElementTypeButton[@text="Make a payment"]" and check the element existence.
Find element by using the element "Coord"
-
- Method -
findByCoord_Click
Click the element
- Method -
Example:
findByCoord_Click("200", "400");
The code means it clicks point of (200, 400).
-
- Method -
findByPoint_ScrollDown
Find elements by using the accessibility id and touch action or use point X, Y to scroll down and up
- Method -
Find element by using the element list based on text
-
1. Method -
findByList_IndexClick
Click the element based on the text
Example:
findByList_IndexClick(30, "com.sprint.care.beta:id/action_btn", "add a new device");
The code means it will take 30 seconds to find elements with resource id of "com.sprint.care.beta:id/action_btn". Then match the text (lower case) "add a new device" and tap the element.
-
2. Method -
findByList_IndexClickMT3
Click the element based on the different text posibilities
Example:
findByList_IndexClick(10, "com.sprint.care.beta:id/action_btn", "upgrade your service", "upgrade now", "early upgrade");
The code means it will take 10 seconds to find elements with resource id of "com.sprint.care.beta:id/action_btn". Then match the text (lower case) "upgrade your service" or "upgrade now" or "early upgrade". And tap the element of matching
Find element by using the element "resource id" if it has.
-
1. Method -
findByResourceID_Click
Click the element
Example1:
findByResourceID_Click(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find and tap the element with resource id of "com.sprint.care.beta:id/action_btn".
Example2:
findByResourceID_Click(10, "com.sprint.care.beta:id/action_btn", true, "Back server error");
The code means it will take 10 seconds to find and tap the element with resource id of "com.sprint.care.beta:id/action_btn". If element not found, the error dialog check will issue and take screenshot if there is any of them. Then let the case fail and back to the main page for next test case.
-
2. Method -
findByResourceID_SendKey
Type in the element, usually the element is text box or field
Example:
findByResourceID_SendKey(10, "com.sprint.care.beta:id/action_btn", "Max");
The code means it will take 10 seconds to find the element with resource id of "com.sprint.care.beta:id/action_btn" and send key " Max" to it.
-
3. Method -
findByResourceID_Clear
Clear the element
Example:
findByResourceID_Clear(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find the element with resource id of "com.sprint.care.beta:id/action_btn" and clear its field value.
-
4. Method -
findByResourceID_GetText
Get text of the element
Example:
findByResourceID_GetText(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find the element with resource id of "com.sprint.care.beta:id/action_btn" and get the text/value
-
5. Method -
findByResourceID_Enable
Check the status of element is enable(true) or disable(false)
Example:
findByResourceID_Enable(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find the element with resource id of "com.sprint.care.beta:id/action_btn" and check the status.
-
6. Method -
findByResourceID_Counts
Check how many elements with same accessibility id
Example:
findByResourceID_Counts(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find the elements with resource id of "com.sprint.care.beta:id/action_btn" and check the elements amount.
-
7. Method -
findByResourceID_Exist
Check the element existence.
Example:
findByResourceID_Exist(10, "com.sprint.care.beta:id/action_btn");
The code means it will take 10 seconds to find the element with resource id of "com.sprint.care.beta:id/action_btn" and check it exist or not.
Find element by using the element "name"
-
1. Method -
findByClassType_Click
Click the element
Example:
findByClassType_Click(10, "Make a payment");
The code means it will take 10 seconds to find and tap the element with the name of "Make a payment".
Find element by using the element "text"
-
1. Method -
findByAndroidUIAutomator_Click
Click the element
Example:
findByAndroidUIAutomator_Click(10, "text(\"Settings\")");
The code means it will take 10 seconds to find and tap the element with the text of "text("Settings")" by using Android UI Automator
-
2. Method -
findByAndroidUIAutomator_Exist
Check the element existence.
Example:
findByAndroidUIAutomator_Exist(10, "text(\"Settings\")");
The code means it will take 10 seconds to find the element with the text of "text("Settings")" by using Android UI Automator and check the existence.
-
3. Method -
findByAndroidUIAutomator_Counts
Check how many elements with same text
Example:
findByAndroidUIAutomator_Counts(10, "text(\"Settings\")");
The code means it will take 10 seconds to find the elements with the text of "text("Settings")" by using Android UI Automator and check the elements amount.
Find element by using the element "Xpath"
-
1. Method -
findByValueXpath_Click
Click the element
Example:
findByValueXpath_Click(10, "text(\"Settings\")");
The code means it will take 10 seconds to find and tap the element with the text of "text("Settings")" by using Xpath.
Find element by using the element "Coord"
-
1. Method -
findByCoord_Click
Click the element
Example:
findByCoord_Click("200", "400");
The code means it will find and tap the spot by using coordinate of x "200" and y "400".
Assert fail and back to the main for preparing the next test.
Show the fail message to the allure result page.