Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari on ios simulator is not loading internal secure sites without warning #9

Open
richardjimenez52 opened this issue Jan 13, 2023 · 7 comments

Comments

@richardjimenez52
Copy link

richardjimenez52 commented Jan 13, 2023

macbook m1 pro
node v16.13.2
nightwatch v2.6.10
safari
iphone8

Trying to run our tests against an internal secure (https) site on safari and I keep getting the warning that the connection is not private even though the site is secure and its on our network. Works as expected when running against desktop browsers but not IOS safari emulator. I can manually bypass it by clicking show details and continue to site but this flow interrupts my automation.

I have tried

Screen Shot 2023-01-13 at 12 39 24 PM

@garg3133
Copy link
Member

Hi, can you try to manually open the simulator by running command open -a simulator and then check if you are able to access this site on Safari browser? This warning usually appears when the SSL certificate of the website is not valid and clearing the browser cache might help. Also, incorrect time set on the clock can also be another reason for this warning. But this issue does not seem to be related to Nightwatch.

@richardjimenez52
Copy link
Author

i'm using acceptInsecureCerts: true in my nightwatch config but it does not seem to be able to bypass this warning.

@garg3133
Copy link
Member

Hi, as mentioned in this StackExchange answer, can you try to execute CertificateWarningController.visitInsecureWebsiteWithTemporaryBypass() as javascript and see if it works for you?

Before navigating to the website, write this step: browser.execute('CertificateWarningController.visitInsecureWebsiteWithTemporaryBypass()').

If the above doesn't work, try this one also: browser.execute('javascript:CertificateWarningController.visitInsecureWebsiteWithTemporaryBypass()').

@garg3133
Copy link
Member

Also, can you share your configuration where you are setting acceptInsecureCerts: true?

@richardjimenez52
Copy link
Author

richardjimenez52 commented Jan 24, 2023

I have tried both scripts and both failed with the following error
Error while running .executeScript() protocol action: A JavaScript exception occured: Can't find variable: CertificateWarningController

I executed the script before navigating to the url in the beforeEach()

Also here is my configuration:

    'ios.simulator.safari': {
      launch_url: "https://dls-wc-ng-test-app.dls-doc-site.dlas1.ucloud.int/smoke",
      //launch_url: "http://localhost:4200/smoke",
      desiredCapabilities: {
        alwaysMatch: {
        //   acceptSsl: false,
           acceptInsecureCerts: true
        },
        browserName: 'safari',
        platformName: 'iOS',
        //platformVersion: '15.0',
        'safari:useSimulator': true,
        // change the deviceName, platformVersion accordingly to run tests on
        // Run command: `xcrun simctl list devices`
        // 'safari:platformVersion': '15.0',
        'safari:deviceName': 'iPhone 14'
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ]
      }
    },

@garg3133
Copy link
Member

Okay, can you try to put acceptInsecureCerts: true outside of alwaysMatch? Like below:

desiredCapabilities: {
  //  acceptSsl: false,
  acceptInsecureCerts: true,
  browserName: 'safari',
  platformName: 'iOS',
  // ...other capabilities

@richardjimenez52
Copy link
Author

richardjimenez52 commented Jan 25, 2023

I have tried placing it outside as well but it is not working either. nightwatch tries to load it and then says it is loaded and then proceeds with the execution of the tests but the site is never really loaded ever and every test fails. If i manually spin up the emulator and go to the page i get the warning but I am able to manually proceed to the page. In the video below you'll see the output of the tests saying it's "loading" and then says "loaded" even though the page never loaded. i navigate to my url in my beforeEach. This long load time only happens because safari on t he ios device is sayign the site is secure so it i attempting to load it. once the site is manually trusted it works as expected

error-https.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants