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

[🐛 Bug]: have a switch to allow offline mode, and don’t check chrome labs when not using chrome #12705

Open
3 tasks done
step21 opened this issue Apr 16, 2024 · 5 comments
Labels
Bug 🐛 good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested

Comments

@step21
Copy link

step21 commented Apr 16, 2024

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

Latest

Node.js Version

20

Mode

Standalone Mode

Which capabilities are you using?

capabilities: [{
        maxInstances: 5,
        browserName: 'firefox',
        acceptInsecureCerts: true,
        'moz:firefoxOptions': {
            args: ['-headless']
        }
    }],

What happened?

I expected to be able to run my tests locally, while being offline due to being on the train or other reasons. Additionally, why is chrome labs being checked when only using Firefox?

What is your expected behavior?

I expected the test to run if it has all the necessary browsers available. It is not an option for me to harcode as mentioned here #10965 as I only need it when offline and do not have custom images. Also imo Firefox should not require a call to chrome labs.

How to reproduce the bug.

Just turn off your internet, have only Firefox in capabilities. Run any test. It will still check chromelabs and not work.

Relevant log output

Execution of 1 workers started at 2024-04-16T14:01:00.207Z

Error: Error: getaddrinfo ENOTFOUND googlechromelabs.github.io
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
Error: getaddrinfo ENOTFOUND googlechromelabs.github.io
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'googlechromelabs.github.io'
}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues
@step21 step21 added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Apr 16, 2024
@christian-bromann
Copy link
Member

I expected to be able to run my tests locally, while being offline due to being on the train or other reasons.

As per our documentation this works if:

If you omit browserVersion, WebdriverIO will first try to locate and use an existing installation with locate-app, otherwise it will download and install the current stable browser release.

So I assume that this application look up has failed which caused WebdriverIO to try to download the binary and driver.

Additionally, why is chrome labs being checked when only using Firefox?

I am not sure why you are experiencing this, I can't reproduce it on my side as I am getting Error: getaddrinfo ENOTFOUND product-details.mozilla.org

Do you have Firefox installed on your OS? If so which path is it on? What OS are you using?

@christian-bromann christian-bromann added Information Missing and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 16, 2024
@step21
Copy link
Author

step21 commented Apr 16, 2024

Thanks for the quick reply. I copied a more readable error message now, somehow it copied weirdly formatted on my phone.
I definitely did not specify a browser version. (should I paste my wdio.conf.js somewhere?)
This is on macOS, and I use Firefox everyday. Also when I am online, it doesn't seem to always redownload.
I just ran locate-app manually, and that gave '/Applications/Firefox.app/Contents/MacOS/Firefox' as a path. This was on node v18 (in my test environment I use both)
Does any of that help?

@christian-bromann
Copy link
Member

@step21 thanks for further details, it seems that WebdriverIO unnecessarily tries to resolve the Firefox version, even though it has all required information to run the test. This causes an unnecessary network hop. A possible fix would be the following:

diff --git a/packages/wdio-utils/src/node/utils.ts b/packages/wdio-utils/src/node/utils.ts
index 93459fe61..8be7bbd84 100644
--- a/packages/wdio-utils/src/node/utils.ts
+++ b/packages/wdio-utils/src/node/utils.ts
@@ -190,16 +190,16 @@ export async function setupPuppeteerBrowser(cacheDir: string, caps: WebdriverIO.
                     linuxWhich: 'chromium-browser'
                 }).catch(() => undefined)
                 : await locateFirefox().catch(() => undefined)
-        const tag = isChromeOrChromium
+        const browserVersion = isChromeOrChromium
             ? getBuildIdByChromePath(executablePath)
             : await getBuildIdByFirefoxPath(executablePath)
         /**
          * verify that we have a valid Chrome/Firefox browser installed
          */
-        if (tag) {
+        if (browserVersion) {
             return {
                 executablePath,
-                browserVersion: await resolveBuildId(browserName, platform, tag)
+                browserVersion
             }
         }
     }

Feel free to raise a PR with the change set.

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested good first pick a reasonable task to start getting familiar with the code base and removed Information Missing labels Apr 16, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

@step21
Copy link
Author

step21 commented Apr 16, 2024

@step21 thanks for further details, it seems that WebdriverIO unnecessarily tries to resolve the Firefox version, even though it has all required information to run the test. This causes an unnecessary network hop. A possible fix would be
...
Feel free to raise a PR with the change set.

Oh wow thanks, that is very helpful, will try to make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

3 participants