-
Notifications
You must be signed in to change notification settings - Fork 1
First commit for Espresso test #462
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
Open
SyedaGini
wants to merge
62
commits into
main
Choose a base branch
from
test-automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
71bef76
First commit for Espresso test
SyedaGini 1f64a50
ci(ui-automation): Add Espresso for GiniBankSDKExample
SyedaGini df1c9ed
ci(ui-automation): Fix requested suggestions
SyedaGini 2d7df38
ci(bank-sdk): Create dedicated workflow for running UI tests
a-szotyori 72a9477
ci(bank-sdk): Fix UI tests workflow
a-szotyori 6b8fcc6
ci(bank-sdk): Run the UI tests from the release workflow
a-szotyori d2ffcb8
ci(bank-sdk): Introduce new test and resource classes.
SyedaGini e66b5c5
Merge branch 'main' into test-automation
a-szotyori f9a0381
refactor(ui-automation): Use string resource ids for the Help Screen
a-szotyori 2aea8c9
ci(bank-sdk): Try running the emulator for UI tests without `-no-window`
a-szotyori 96fd6fc
refactor(ui-automation): Use resource ids for the Onboarding Screen T…
SyedaGini 88dd996
ci(ui-automation): Introduce new screen and test classes
SyedaGini 1de6c50
ci(bank-sdk): Revert running the emulator for UI tests without `-no-w…
a-szotyori e097417
ci: Update emulator Android API level for UI tests to 34
a-szotyori 3b858f1
Merge branch 'main' into test-automation
a-szotyori e33a4b6
ci (ui-automation): Resolved CaptureScreen ui-tests and added Extract…
SyedaGini 06d1db4
ci (ui-automation): Implemented test-cases for Extraction Screen
SyedaGini 61e5d08
refactor(ui-automation): Added assertion for test-cases and updated e…
SyedaGini ac9ea32
ci (ui-automation): added function to ExtractionScreen
SyedaGinii 6a17f53
ci (ui-automation): added ReviewScreenTests
SyedaGinii 03e7594
ci (ui-automation): added test-cases for ImportPdfImageTest.kt
SyedaGinii 050ddbe
refactor(ui-automation): Update PdfUploader.Kt and mutliple test-classes
SyedaGinii 0673760
Added automation for Digital Invoice Screen
SyedaGinii 0438289
ci(ui-automation): Push test documents to emulator before running UI …
a-szotyori beb4231
Address comments on PR
SyedaGinii ae34c24
Added automation for No Result Screen
SyedaGinii 4d2b4ef
Fixed comments on PR
SyedaGinii d081257
Addressed comments on PR
SyedaGinii 052c50f
Addressed comments on PR
SyedaGinii 55088e6
Merge pull request #574 from gini/automation(no-result-screen)
SyedaGinii 233ab1b
Added assertion for checks
SyedaGinii 9e2869d
Merge branch 'test-automation' into automation(digital-invoice-screen)
SyedaGinii 4d30565
Merge pull request #565 from gini/automation(digital-invoice-screen)
SyedaGinii b8c126f
Added automation for File Import Error Screen
SyedaGinii 50fedb8
Remove toast assertion from test-cases
SyedaGinii 2825b0b
Merge pull request #580 from gini/automation(file-import-error-dialog)
SyedaGinii 0546575
Added automation for Edit Button on Digital Invoice Screen
SyedaGinii ff585d7
Addressed comment on PR
SyedaGinii 623d37c
Merge pull request #587 from gini/automation(edit-button-digital-invo…
SyedaGinii 6d90b76
Added automation for Error Screens
SyedaGinii 1cc32a5
Added test-case number 2 with validations
SyedaGinii 5b7c09e
Merge pull request #589 from gini/automation(errors-screen)
SyedaGinii 501766c
ci: Add adb push command to CI
e2e03d8
ci: Add sample documents for UI tests
b51e147
fix:(bank-sdk) Add delay for tests. Add scroll search of file
ad442be
ci: Fix api-level of emulator
ade70e3
Merge pull request #600 from gini/PP-860_automation_test_files
GeraltRiv c566d77
ci: Fix failing tests for assertions
SyedaGinii 16fb023
ci: Add scrollTo option
8f6dc36
Merge pull request #607 from gini/PM-122_test-automation_scroll_to
GeraltRiv 46f2cec
Merge pull request #605 from gini/PM-122-fix-failing-test-cases
SyedaGinii 6b3eae0
ci: Fix failing test of CaptureScreenTests > test2_flashEnabledWhenIm…
SyedaGinii ebffcfa
Merge pull request #608 from gini/PM-122-fix-failing-test-cases
SyedaGinii 1d1263c
test: (bank-sdk) Add possibility to skip tests
be13e08
ci: Add possibility to skip tests
44fca15
Merge pull request #613 from gini/PM-122_test-automation_skip_photo_p…
GeraltRiv d4e4f65
bank-sdk test
26df142
bank-sdk test
8ade701
test
39aa1a0
test
8de117e
test
71e2e45
test
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
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Check Bank SDK - UI Tests | ||
|
||
# TODO: Update triggers to execute only on workflow_call (from the release workflow) and via manual triggering | ||
# (UI tests are slow and we should not run them on every push) | ||
on: | ||
push: | ||
paths: | ||
- 'bank-sdk/**' | ||
- 'capture-sdk/**' | ||
- 'bank-api-library/**' | ||
- 'core-api-library/**' | ||
- 'gradle/**' | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
pull_request: | ||
types: [opened, edited, reopened] | ||
paths: | ||
- 'bank-sdk/**' | ||
- 'capture-sdk/**' | ||
- 'bank-api-library/**' | ||
- 'core-api-library/**' | ||
- 'gradle/**' | ||
workflow_call: | ||
secrets: | ||
GINI_MOBILE_TEST_CLIENT_SECRET: | ||
required: true | ||
|
||
jobs: | ||
ui-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: setup java | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'gradle' | ||
|
||
- name: enable KVM group perms for emulator | ||
run: | | ||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
sudo udevadm control --reload-rules | ||
sudo udevadm trigger --name-match=kvm | ||
|
||
- name: avd cache | ||
uses: actions/cache@v4 | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: avd-x86_64-34-${{ github.ref_name }} | ||
|
||
- name: create avd and generate snapshot for caching | ||
if: steps.avd-cache.outputs.cache-hit != 'true' | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 34 | ||
arch: x86_64 | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -no-audio -no-boot-anim -camera-back emulated | ||
disable-animations: true | ||
script: echo "Generated AVD snapshot for caching." | ||
|
||
- name: run example app instrumented tests | ||
timeout-minutes: 20 | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 34 | ||
arch: x86_64 | ||
force-avd-creation: false | ||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back emulated | ||
disable-animations: true | ||
script: > | ||
adb uninstall net.gini.android.bank.sdk.exampleapp.test ; | ||
adb push bank-sdk/example-app/src/androidTest/testDocuments/test_image.jpeg /sdcard/Download ; | ||
adb shell am start -a android.intent.action.VIEW -n com.google.android.apps.photos/.home.HomeActivity -d file:///sdcard/Download/test_image.jpeg ; | ||
adb push bank-sdk/example-app/src/androidTest/testDocuments/Testrechnung-RA-1.pdf /sdcard/Download ; | ||
adb push bank-sdk/example-app/src/androidTest/testDocuments/sample.pdf /sdcard/Download ; | ||
./gradlew bank-sdk:example-app:connectedDevExampleAppDebugAndroidTest | ||
-PclientId="gini-mobile-test" | ||
-PclientSecret="${{ secrets.GINI_MOBILE_TEST_CLIENT_SECRET }}" | ||
|
||
- name: archive instrumented test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bank-sdk-example-app-instrumented-test-results | ||
path: bank-sdk/example-app/build/outputs/androidTest-results/connected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...p/src/androidTest/java/net/gini/android/bank/sdk/exampleapp/ui/resources/ImageUploader.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.gini.android.bank.sdk.exampleapp.ui.resources | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiSelector | ||
|
||
|
||
class ImageUploader { | ||
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
fun uploadImageFromPhotos() { | ||
device.waitForIdle() | ||
val selectPhoto = device.findObject( | ||
UiSelector() | ||
.className("android.widget.ImageView") | ||
.resourceId("com.google.android.providers.media.module:id/icon_thumbnail") | ||
) | ||
if (selectPhoto != null) { | ||
selectPhoto.click() | ||
} else { | ||
throw Exception("First photo not found") | ||
} | ||
} | ||
|
||
fun clickAddButton() { | ||
val addButton = device.findObject( | ||
UiSelector() | ||
.className("android.widget.Button") | ||
.resourceId("com.google.android.providers.media.module:id/button_add") | ||
) | ||
if (addButton.exists()) { | ||
addButton.click() | ||
} else { | ||
throw java.lang.Exception("Add button not found") | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...app/src/androidTest/java/net/gini/android/bank/sdk/exampleapp/ui/resources/PdfUploader.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.gini.android.bank.sdk.exampleapp.ui.resources | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiScrollable | ||
import androidx.test.uiautomator.UiSelector | ||
|
||
class PdfUploader { | ||
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
fun uploadPdfFromFiles(file: String) { | ||
device.waitForIdle() | ||
|
||
// Assuming you’re on the main screen of the Files app, search for the PDF file by name | ||
val fileList = UiScrollable(UiSelector().scrollable(true)) | ||
|
||
// Find the PDF file by name and click on it | ||
val tabTitle = device.findObject(UiSelector().className("android.widget.TextView").text("Recent")) | ||
if (tabTitle.exists()) { | ||
// Interact with hamburger menu | ||
val hamburgerMenu = device.findObject(UiSelector().className("android.widget.ImageButton")) | ||
hamburgerMenu.exists() | ||
hamburgerMenu.click() | ||
|
||
// Click the 'Downloads' option | ||
val downloadsOption = device.findObject(UiSelector() | ||
.className("android.widget.TextView") | ||
.text("Downloads")) | ||
downloadsOption.exists() | ||
downloadsOption.click() | ||
val selectPdfFile = fileList.getChildByText(UiSelector().text(file), file) | ||
selectPdfFile.click() | ||
} | ||
else { | ||
// Select desired pdf file | ||
val selectPdfFile = fileList.getChildByText(UiSelector().text(file), file) | ||
selectPdfFile.click() | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ndroidTest/java/net/gini/android/bank/sdk/exampleapp/ui/resources/SimpleIdlingResource.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.gini.android.bank.sdk.exampleapp.ui.resources | ||
import androidx.test.espresso.IdlingResource | ||
|
||
class SimpleIdlingResource(private val waitTime: Long) : IdlingResource { | ||
|
||
@Volatile | ||
private var isIdleNow = true | ||
private var callback: IdlingResource.ResourceCallback? = null | ||
|
||
override fun getName() = SimpleIdlingResource::class.java.name | ||
|
||
override fun isIdleNow() = isIdleNow | ||
|
||
override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback) { | ||
this.callback = callback | ||
} | ||
|
||
fun setIdleState(isIdleNow: Boolean) { | ||
this.isIdleNow = isIdleNow | ||
if (isIdleNow && callback != null) { | ||
callback!!.onTransitionToIdle() | ||
} | ||
} | ||
|
||
fun waitForIdle() { | ||
isIdleNow = false | ||
Thread { | ||
try { | ||
Thread.sleep(waitTime) | ||
} catch (e: InterruptedException) { | ||
e.printStackTrace() | ||
} | ||
setIdleState(true) | ||
}.start() | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.