Skip to content

Commit

Permalink
wait inorder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Song committed Dec 12, 2024
1 parent b9d2bce commit e6ba073
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions IdentityCore/tests/automation/ui_tests_lib/MSIDBaseUITest.m
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,29 @@ - (void)enterPassword:(NSString *)password app:(XCUIApplication *)application is
// Enter password
XCUIElement *passwordSecureTextField = [application.secureTextFields elementBoundByIndex:0];
// This is explicitly to check the new screen where to ask user to signin with the following 2 options. This caused several automation failures
// 1. Use my password
// 2. Sign in to an orgnization
XCUIElement *useMyPasswordButton = application.buttons[@"Use my password"];
XCUIElement *currentElement = [self waitForEitherElements:passwordSecureTextField and:useMyPasswordButton];
if (currentElement.elementType == XCUIElementTypeButton)

XCTWaiterResult result = [self waitForElementsAndContinue:passwordSecureTextField];
if (result == XCTWaiterResultCompleted)
{
[currentElement tap];
[self enterPassword:password
app:application
isMainApp:isMainApp];
return;
[self tapElementAndWaitForKeyboardToAppear:passwordSecureTextField app:application];
NSString *passwordString = [NSString stringWithFormat:@"%@\n", password];
[self enterText:passwordSecureTextField isMainApp:isMainApp text:passwordString];
}
else
{
// 1. Use my password
// 2. Sign in to an orgnization
XCUIElement *useMyPasswordButton = application.buttons[@"Use my password"];
result = [self waitForElementsAndContinue:useMyPasswordButton];
if (result == XCTWaiterResultCompleted)
{
[useMyPasswordButton tap];
[self enterPassword:password
app:application
isMainApp:isMainApp];
}
}

[self tapElementAndWaitForKeyboardToAppear:passwordSecureTextField app:application];
NSString *passwordString = [NSString stringWithFormat:@"%@\n", password];
[self enterText:passwordSecureTextField isMainApp:isMainApp text:passwordString];
}

- (void)adfsEnterPassword:(XCUIApplication *)application
Expand Down Expand Up @@ -487,6 +494,14 @@ - (XCUIElement *)waitForEitherElements:(XCUIElement *)object1 and:(XCUIElement *
return object1.exists ? object1 : object2;
}

- (XCTWaiterResult)waitForElementsAndContinue:(XCUIElement *)object
{
NSPredicate *existsPredicate = [NSPredicate predicateWithFormat:@"%@.exists == 1" argumentArray:@[object]];

XCTestExpectation *expectation = [[XCTNSPredicateExpectation alloc] initWithPredicate:existsPredicate object:object];//[self expectationForPredicate:existsPredicate evaluatedWithObject:nil handler:nil];
return [XCTWaiter waitForExpectations:@[expectation] timeout:10.0f enforceOrder:YES];
}

- (void)tapElementAndWaitForKeyboardToAppear:(XCUIElement *)element
{
[self tapElementAndWaitForKeyboardToAppear:element app:[XCUIApplication new]];
Expand Down

0 comments on commit e6ba073

Please sign in to comment.