How can I bypass the login screen programmatically?

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/ I/okhttp.OkHttpClient: <-- END HTTP (146-byte body)
2022-06-16 10:24:41.449 6080-7183/ D/UnauthorizedInterceptor: Received 401:
2022-06-16 10:24:41.466 6080-7183/ I/CompanyNameClient: NETWORK ERROR CODE 401


capabilities: [{
        platformName: 'Android',
        'appium:deviceName': 'Android Emulator',
        'appium:app': '/Users/dpg/Desktop/App-debug.apk',
        'appium:appActivity': "",
        'appium:unicodeKeyboard': false,
        'appium:resetKeyboard': false,

My Test Code:

      it.only("log in using correct email and password", async () => {
        await loginFlowElements.loginBtn.waitForDisplayed();

    // 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 {
    } catch (error) {
        "Something went wrong at authLoginBtn. Caught this error: ",
   // Wait a long time to see if it logs in. App crashes while test is waiting.
    await driver.pause(30000);

Does it work on a real device? I’d say file a bug, but I’m sure developers would need you to reproduce on a real device to call it a bug.

For bypassing the login, only way would be to have developers do that on a debug version. Login is an essential part of most apps.

1 Like

Thank you for your message :slight_smile: It unfortunately doesn’t work on a real device either. This occurs only when Appium is involved in the process (ie. launching the app using the Appium Inspector or running the Appium test) but I’m able to log in manually without using Appium. I was wondering if I needed to somehow authorize the device since I saw the error? UnauthorizedInterceptor: Received 401.

Thanks again!

I would seriously take a look at the device log and any logs that your app produces. I get device logs with showIosLog capability:

I would also talk this over with a developer asap. It may be they could shed some light on why this is happening. I’m not sure if the 401 error is part of the problem as I don’t understand exactly how your app works.

1 Like

you are awesome! thank you so much!