wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.2k stars 1.92k forks source link

Bypass save password prompt #3761

Open NatalieDinh opened 1 year ago

NatalieDinh commented 1 year ago

Description

Hi,

I was wondering if there was a permission that we would be able to set to bypass the save password prompt, similarly to how we are able to bypass notifications/locations prompt.

Screen Shot 2022-12-15 at 3 52 52 PM

Your environment

Detox version: ^19.6.5, React Native version: ^0.69.1, Node version: v14.17.0 Device model: iPhone 13 OS: 15 Test-runner: jest

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

noomorph commented 1 year ago

Asaf, please look 👀 @asafkorem

stale[bot] commented 1 year ago

The issue has been closed for inactivity.

angelica-snowit commented 1 year ago

With the new XCode update my tests fails because of the password prompt. As already asked: there is a permission that we would be able to set to bypass the save password prompt?

owens-ben commented 1 year ago

Having the same issue, Xcode 14.3.

fossage commented 1 year ago

Also seeing the same thing after updating to Xcode 14.3. Our current workaround is just falling back to Xcode 14.2(you can get it via this link). If the problem persists and it doesn't seem easily fixable, we will likely set up some logic to log the test user in without actually using the password input if thats helpful for anyone else..

owens-ben commented 1 year ago

Rolled back to 14.2, not seeing the issue anymore.

simonedif commented 1 year ago

Having the same issue with Xcode 14.3. As already mentioned is there a way that we would able to set to bypass the save password prompt?

JasonHiew commented 1 year ago

Am new to Detox and also faced the same issue and would rather not downgrade Xcode to 14.2 bc of the fairly large download size and it not detecting my iPhone which has been updated to iOS 16.4.1 already.

Not sure if this helps in your case. I don't think this has been mentioned anywhere else.

I found a rather simple workaround. By backgrounding the app and opening it back, the "Save Password" prompt goes away.

Put this in the sign in test case:

await device.sendToHome();
await device.launchApp({ newInstance: false });

The whole thing should look like this (Maybe, I'm new to Detox and all code testing in general):

 it('should sign in', async () => {
    await element(by.text('SIGN IN')).tap();

    await element(by.id('email')).typeText('test@gmail.com');
    await element(by.id('password')).typeText('password');
    await element(by.text('SIGN IN')).tap();

    await device.sendToHome();
    await device.launchApp({ newInstance: false });

    await expect(element(by.text('Home screen'))).toBeVisible();
  });
});
noomorph commented 1 year ago

@asafkorem please answer

asafkorem commented 1 year ago

Hello @NatalieDinh, unfortunately, the save password prompt is a system dialog, so we are unable to provide a solution through Detox or AppleSimUtils. We recommend tracking this issue related to XCUITest integration: https://github.com/wix/Detox/issues/3208. This upcoming solution for Detox iOS will allow for interaction with system dialogs, addressing cases like yours.

In the meantime, you can manually disable the Autofill feature for passwords on the iOS Simulator, which should alleviate the issue (https://stackoverflow.com/questions/55378639/strong-password-autofill-appears-in-ios-simulator): Navigate to Simulator -> Settings -> Passwords, and toggle the AutoFill passwords option off by first turning it on and then turning it off.

asafkorem commented 1 year ago

@JasonHiew this workaround is interesting, I wonder if it works for older/newer Xcode versions as well. How did you found it? I wonder if it's an iOS feature or bug.

JasonHiew commented 1 year ago

@asafkorem I found it by accident through trial and error while checking the docs since I couldn't find any solution without downgrading Xcode or modifying the existing form.

I think this workaround will work regardless of Xcode version. On older Xcode versions, as mentioned by others, doesn't have the prompt. As long as app doesn't background itself in the middle of the login process, I don't see why it wouldn't work.

It should instead depend on the way the "Save Password" prompt is handled by the iOS version. Can't guarantee that it'll work on all iOS versions. Have not tested it myself on other iOS versions, but it should work as long as the prompt behaves like this (closes after backgrounding the app).

roryf commented 1 year ago

This seems like a major blocker for upgrading to 14.3 until https://github.com/wix/Detox/issues/3208 is concluded, is there no way to programmatically disable AutoFill via simulator options or something?

mdolinin commented 1 year ago

I have used this workaround using plutil -> https://stackoverflow.com/a/76105538 Example:

beforeAll(async () => {
    if (device.getPlatform() === 'ios') {
      // disable password autofill
      execSync(
        `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles/UserSettings.plist`,
      );
      execSync(
        `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/EffectiveUserSettings.plist`,
      );
      execSync(
        `plutil -replace restrictedBool.allowPasswordAutoFill.value -bool NO ~/Library/Developer/CoreSimulator/Devices/${device.id}/data/Library/UserConfigurationProfiles/PublicInfo/PublicEffectiveUserSettings.plist`,
      );
    }
    await device.launchApp();
  });

Tested on Xcode 14.3 and iOS 16.4

noomorph commented 1 year ago

@asafkorem looks like it is interesting workaround too with plists.

Also, do I understand right that Detox 21.0.0 will solve this issue or not?

andac-ozcan commented 1 year ago

@mdolinin's solution worked flawless on my side. I just had to add below:

const execSync = require('child_process').execSync;

asafkorem commented 1 year ago

@asafkorem looks like it is interesting workaround too with plists.

Also, do I understand right that Detox 21.0.0 will solve this issue or not?

You understand correctly, it will enable interactions with system dialogs.

The workaround looks interesting. I believe we can refer to this issue from the docs for the meanwhile..

grgmo commented 1 year ago

@mdolinin's workaround works for me only if I do the execSync part after await device.launchApp();

On checking those plist files for some reason putting execSync before await device.launchApp(); does not change the values, but putting it after gives me correct values

@JasonHiew's workaround also works

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

risinglf commented 1 year ago

Hello, any news about this?

SandroMachado commented 1 year ago

Facing the same issue.

owens-ben commented 1 year ago

Seeing the same issue in xcode 14.3.1

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

angelica-snowit commented 1 year ago

Still a valid request.

stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

mokagio commented 10 months ago

I'm not a Detox user, but landed here because Xcode 15.1 and iOS 17.2 broke the Simulator -> Settings -> Passwords -> Disable AutoFill we had implemented via registering a test observer (XCTestObservation).

The reason, as far as I can tell, is that as soon as the Passwords screen is pushed in the navigation stack, it's popped back:

https://github.com/wix/Detox/assets/1218433/4dd84b23-8535-4d9e-ab27-e6f7d6925f38

Unfortunately, this is all I have to offer. It doesn't help much in terms of finding a solution, but hopefully can serve as a good explanation for folks who experience this issue anew.

stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

manu-abrantes commented 6 months ago

Having the same issue in Xcode 15.2

owens-ben commented 3 months ago

This is still an issue, Xcode 15.1 and 15.2, and only on iphone 15.