Unable to automate microsoft sign in page

I am able to see the home page automated however when the microsoft sign in page is launched
it is not able to automated
using the appium inspector and accessibility inspector, the locator strategy is correctly set
the error seen is
Request failed with status 404 due to A session is either terminated or not started

here is the appium log

Can you reproduce locally? It’s very hard for anyone here to replicate Browserstack errors as we would have to pay for the service.

this is run locally on iOS Simulator. not on BS yet.

Ok. What is the code on this? I’m seeing that the deleteSession comand is given and then you start getting 404’s:

[0-1] e[90m2022-08-11T08:17:18.037Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: e[33mDATAe[39m { using: 'accessibility id', value: 'Enter your email or phone' }
[0-1] e[90m2022-08-11T08:17:18.048Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: e[35mCOMMANDe[39m deleteSession()
[0-1] e[90m2022-08-11T08:17:18.048Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: [DELETE] http://localhost:4723/session/6c5196f6-1ec1-4c80-bc71-d2487983998b
[0-1] e[90m2022-08-11T08:17:18.191Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: e[36mRESULTe[39m {
[0-1]   'element-6066-11e4-a52e-4f735466cecf': '0D000000-0000-0000-E283-000000000000',
[0-1]   ELEMENT: '0D000000-0000-0000-E283-000000000000'
[0-1] }
[0-1] e[90m2022-08-11T08:17:18.193Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: e[35mCOMMANDe[39m isElementDisplayed("0D000000-0000-0000-E283-000000000000")
[0-1] e[90m2022-08-11T08:17:18.194Ze[39m e[96mINFOe[39m e[97mwebdrivere[39m: [GET] http://localhost:4723/session/6c5196f6-1ec1-4c80-bc71-d2487983998b/element/0D000000-0000-0000-E283-000000000000/displayed
[0-1] e[90m2022-08-11T08:17:18.227Ze[39m e[33mWARNe[39m e[97mwebdrivere[39m: Request failed with status 404 due to A session is either terminated or not started

By the way, I’d like to thank you for posting as a gist. So much easier to read.

here is the code snippet using webdriverio API

import Page from './page';
import { config } from '../../../config/wdio.conf'
import { setTimeout } from 'timers/promises';

/**
 * sub page containing specific selectors and methods for a specific page
 */

const SELECTORS = {
  EMAIL_OR_PHONE: '~Enter your email or phone',
  CANNOT_ACCESS_ACCOUNT_LINK: '~Can’t access your account?',
  NEXT: '~Next',
  SIGN_IN_OPTIONS: '~Sign-in options, Sign-in options',
  
  	
  EMAIL_OR_PHONE_IOS: '//XCUIElementTypeTextField[@name="Enter your email or phone"]',
  CANNOT_ACCESS_ACCOUNT_LINK_IOS: '//XCUIElementTypeStaticText[@name="Can’t access your account?"]',
  NEXT_IOS: '//XCUIElementTypeButton[@name="Next"]',
  SIGN_IN_OPTIONS_IOS: '//XCUIElementTypeButton[@name="Sign-in options, Sign-in options"]'

  // IOS

  // ANDROID
};

class ADLoginPage extends Page {

  async enterEmail(email) {
        (await $(SELECTORS.NEXT).waitForDisplayed()) &&
        (await $(SELECTORS.NEXT).touchAction('tap'));
       
  }

   open() {
    return super.open('ADlogin');
  }
}

export default new ADLoginPage();

here is the step defn to call the function

import 'expect-webdriverio'

import { DataTable, Given, Then, When } from '@cucumber/cucumber'
import { Actor} from '@serenity-js/core';
import HomePage from '../page-objects/HomePage';
import ADLoginPage from '../page-objects/ADLoginPage';
import { setTimeout } from 'timers/promises';

Given('{actor} has selected the login via azure option', async (actor: Actor) => {
  await HomePage.selectAzureADLogin();
});

When(
  '{pronoun} enters a valid registered email',
  async function (actor: Actor, table: DataTable) {
    const email = table.hashes()[0].email;
    await setTimeout(5000, 'resolved')
    ADLoginPage.enterEmail(email)
  },
);

Then('{pronoun} should be successfully logged in', async function (actor: Actor) {
});

I will try to set up a stand alone React native project to replicate this issue

here is the recording

This method defaults to 0.5 seconds before timeout. What happens if you increase that time? Has the page even finished loading? I would start with a large number and decrease once you’ve got it working.

Also, if the timeout is throwing some exception that in turn is calling deleteSession, you should try to catch the exception and handle it some other way if you aren’t ready to delete the session.

yes the page is fully loaded even with the default timeout for waitForDisplayed, I notice this message from the log

-1] 2022-08-17T05:46:35.955Z INFO webdriver: DATA {
[0-1]   using: 'xpath',
[0-1]   value: '//XCUIElementTypeTextField[@name="Enter your email or phone"]'
[0-1] }
[0-1] 2022-08-17T05:46:35.967Z INFO webdriver: COMMAND deleteSession()
[0-1] 2022-08-17T05:46:35.967Z INFO webdriver: [DELETE] http://localhost:4723/session/ae6b83e8-ed1f-40d2-823a-023ed821cd26
[0-1] 2022-08-17T05:46:36.217Z INFO webdriver: RESULT {
[0-1]   'element-6066-11e4-a52e-4f735466cecf': '0D000000-0000-0000-9573-010000000000',
[0-1]   ELEMENT: '0D000000-0000-0000-9573-010000000000'
[0-1] }
[0-1] 2022-08-17T05:46:36.219Z INFO webdriver: COMMAND isElementDisplayed("0D000000-0000-0000-9573-010000000000")
[0-1] 2022-08-17T05:46:36.219Z INFO webdriver: [GET] http://localhost:4723/session/ae6b83e8-ed1f-40d2-823a-023ed821cd26/element/0D000000-0000-0000-9573-010000000000/displayed
[0-1] 2022-08-17T05:46:36.270Z WARN webdriver: Request failed with status 404 due to A session is either terminated or not started
[0-1] 2022-08-17T05:46:36.270Z INFO webdriver: Retrying 1/5
[0-1] 2022-08-17T05:46:36.270Z INFO webdriver: [GET] http://localhost:4723/session/ae6b83e8-ed1f-40d2-823a-023ed821cd26/element/0D000000-0000-0000-9573-010000000000/displayed
[0

as soon as it found the xpath for the email element in the microsoft page, it called the deleteSession

I wonder what cause this deleteSession in appium?

my code snippet

  async enterEmail(email) {
        (await $(SELECTORS.EMAIL_OR_PHONE_IOS).waitForDisplayed()) &&
        (await $(SELECTORS.EMAIL_OR_PHONE_IOS).touchAction('tap'));
        await $(SELECTORS.EMAIL_OR_PHONE_IOS).setValue(email)
       
  }

the selector $(SELECTORS.NEXT) is in the same microsoft sign in page, it make no difference to use
$(SELECTORS.EMAIL_OR_PHONE_IOS)

Do you have the ability to debug this code and step through? I’m not seeing anything abnormal. I feel like there is some side effect from a library or hook somewhere that might be obvious in a debug session.

@wreed. this issue is resolved.
it’s due this line in my code
await ADLoginPage.enterEmail(email)

in
When(
‘{pronoun} enters a valid registered email’,
async function (actor: Actor, table: DataTable) {
const email = table.hashes()[0].email;
await setTimeout(5000, ‘resolved’)
await ADLoginPage.enterEmail(email)
}
);

1 Like

to clarify, earlier, I miss out the await for this line.