Hello all, I’ve been trying to write tests for an app that has an authentication screen, but going through the the basic login with email and password seems to crash the app when I use Appium. I’m able to reproduce the same behavior using the Appium Inspector tool trying to enter email and password and tap the Log In button.
Is there a way I can bypass the login screen programmatically by injecting some sort of cookie or something similar?
I’ve tried to debug the issue and saw the following errors in the logs. Not sure how to solve this:
2022-06-16 10:24:41.446 6080-7183/com.companyname.android.appname.debug I/okhttp.OkHttpClient: <-- END HTTP (146-byte body)
2022-06-16 10:24:41.449 6080-7183/com.companyname.android.appname.debug D/UnauthorizedInterceptor: Received 401: https://login.companyname.com/api/1/login/oauth/provider/tokens
2022-06-16 10:24:41.466 6080-7183/com.companyname.android.appname.debug I/CompanyNameClient: NETWORK ERROR CODE 401
Capabilities:
capabilities: [{
platformName: 'Android',
'appium:deviceName': 'Android Emulator',
'appium:app': '/Users/dpg/Desktop/App-debug.apk',
'appium:appActivity': "com.companyname.android.onboarding.views.WelcomeActivity",
'appium:unicodeKeyboard': false,
'appium:resetKeyboard': false,
My Test Code:
it.only("log in using correct email and password", async () => {
await loginFlowElements.loginBtn.waitForDisplayed();
await loginFlowElements.loginBtn.click();
// Set correct email
await loginFlowElements.emailField.waitForDisplayed();
await loginFlowElements.emailField.clearValue();
await loginFlowElements.emailField.setValue("[email protected]");
// Set correct password
await loginFlowElements.passwordField.waitForDisplayed();
await loginFlowElements.passwordField.clearValue();
await loginFlowElements.passwordField.setValue("testingpassword");
await loginFlowElements.authLoginBtn.waitForDisplayed();
try {
await loginFlowElements.authLoginBtn.click();
} catch (error) {
console.log(
"Something went wrong at authLoginBtn. Caught this error: ",
error
);
}
// Wait a long time to see if it logs in. App crashes while test is waiting.
await driver.pause(30000);
});