Detox icon indicating copy to clipboard operation
Detox copied to clipboard

Bypass save password prompt

Open NatalieDinh opened this issue 2 years ago • 30 comments

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

NatalieDinh avatar Dec 15 '22 23:12 NatalieDinh

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.

stale[bot] avatar Jan 15 '23 23:01 stale[bot]

Asaf, please look 👀 @asafkorem

noomorph avatar Jan 16 '23 05:01 noomorph

The issue has been closed for inactivity.

stale[bot] avatar Feb 05 '23 07:02 stale[bot]

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?

angelica-snowit avatar Apr 05 '23 11:04 angelica-snowit

Having the same issue, Xcode 14.3.

owens-ben avatar Apr 06 '23 19:04 owens-ben

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..

fossage avatar Apr 06 '23 21:04 fossage

Rolled back to 14.2, not seeing the issue anymore.

owens-ben avatar Apr 07 '23 14:04 owens-ben

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?

simonedif avatar Apr 20 '23 11:04 simonedif

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('[email protected]');
    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();
  });
});

JasonHiew avatar Apr 25 '23 03:04 JasonHiew

@asafkorem please answer

noomorph avatar Apr 25 '23 05:04 noomorph

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 avatar Apr 25 '23 06:04 asafkorem

@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.

asafkorem avatar Apr 25 '23 06:04 asafkorem

@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).

JasonHiew avatar Apr 25 '23 08:04 JasonHiew

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?

roryf avatar Apr 26 '23 17:04 roryf

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

mdolinin avatar Apr 26 '23 19:04 mdolinin

@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?

noomorph avatar Apr 27 '23 04:04 noomorph

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

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

andac-ozcan avatar Apr 27 '23 13:04 andac-ozcan

@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..

asafkorem avatar Apr 27 '23 14:04 asafkorem

@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

grgmo avatar Apr 27 '23 16:04 grgmo

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.

stale[bot] avatar Jun 10 '23 11:06 stale[bot]

Hello, any news about this?

risinglf avatar Jun 12 '23 22:06 risinglf

Facing the same issue.

SandroMachado avatar Jul 13 '23 14:07 SandroMachado

Seeing the same issue in xcode 14.3.1

owens-ben avatar Jul 14 '23 15:07 owens-ben

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.

stale[bot] avatar Sep 16 '23 21:09 stale[bot]

Still a valid request.

angelica-snowit avatar Sep 18 '23 07:09 angelica-snowit

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.

stale[bot] avatar Dec 15 '23 04:12 stale[bot]

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.

mokagio avatar Dec 15 '23 05:12 mokagio

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.

stale[bot] avatar Mar 17 '24 08:03 stale[bot]

Having the same issue in Xcode 15.2

manu-abrantes avatar Apr 03 '24 10:04 manu-abrantes

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

owens-ben avatar Jul 11 '24 16:07 owens-ben