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

click on android identifier instead of string identifier #12041

Draft
wants to merge 18 commits into
base: trunk
Choose a base branch
from
Draft
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 .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ steps:
command: .buildkite/commands/run-instrumented-tests.sh
plugins:
- $CI_TOOLKIT
- $TEST_COLLECTOR :
- $TEST_COLLECTOR:
<<: *test_collector_common_params
api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_INSTRUMENTED_TESTS"
artifact_paths:
Expand Down
3 changes: 2 additions & 1 deletion WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ fladle {
"notPackage com.woocommerce.android.e2e.tests.screenshot"
]
devices = [
[ "model": "Pixel2.arm", "version": "30" ]
[ "model": "Pixel2.arm", "version": "30" ],
[ "model": "MediumTablet.arm", "version": "32", orientation: "landscape" ]
]
localResultsDir = "$rootDir/build/instrumented-tests"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.woocommerce.android.R
import com.woocommerce.android.e2e.helpers.util.NestedScrollViewExtension
import com.woocommerce.android.e2e.helpers.util.Screen
import com.woocommerce.android.e2e.screens.moremenu.MoreMenuScreen
import org.junit.Assert

class SettingsScreen : Screen {
// Using HELP_BUTTON even if we don't need to interact with it because for some reason Espresso can't find
Expand Down Expand Up @@ -57,11 +58,38 @@ class SettingsScreen : Screen {
Espresso.onView(ViewMatchers.withId(R.id.btn_option_logout)).perform(NestedScrollViewExtension())
}

waitForElementToBeDisplayed(R.id.btn_option_logout)
clickOn(R.id.btn_option_logout)
// retry in case log out pop up doesn't work the first time
retryAction({
// click log out menu item
waitForElementToBeDisplayed(R.id.btn_option_logout)
clickOn(R.id.btn_option_logout)

// Confirm Log Out
waitForElementToBeDisplayed(android.R.id.button1) // sign out button is an Android system resources identifier
clickButtonInDialogWithTitle(R.string.signout)
// confirm log out action
// sign out button is an Android system resources identifier
waitForElementToBeDisplayed(android.R.id.button1)
clickOn(android.R.id.button1)
})

// login screen should be displayed after logging out
waitForElementToBeDisplayed((R.id.button_login_store))
}

private fun retryAction(action: () -> Unit, maxAttempts: Int = 3) {
var attempts = 0
var success = false
var lastError: AssertionError? = null
while (!success && attempts < maxAttempts) {
try {
action()
success = true
} catch (e: AssertionError) {
lastError = e // Capture the last AssertionError
Thread.sleep(1000) // Wait for 1 second before retrying
attempts++
}
}
if (!success) {
Assert.fail("Failed to perform action after $maxAttempts attempts with error $lastError")
}
}
}
Loading