SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.72k stars 739 forks source link

selenium-side-runner thrown timeout error #1811

Open jackchuong opened 2 months ago

jackchuong commented 2 months ago

Hi all, I apologize for the inconvenience if my topic is inappropriate in this group. On my Windows 10, I have Chrome browser Version 123.0.6312.123 (Official Build) (64-bit) with Selenium IDE extension installed. I recorded a simple test like access to https://opensource-demo.orangehrmlive.com/ --> login --> logout , saved as test3.side I can run test with Selenium IDE successfully.

I installed nodejs and npm

C:\Users\jack.chuong\Downloads>node -v
v20.12.2

C:\Users\jack.chuong\Downloads>npm -v
10.5.0

Then I use npm to install selenium-side-runner and chromedriver

C:\Users\jack.chuong\Downloads>selenium-side-runner --version
4.0.4

C:\Users\jack.chuong\Downloads>chromedriver --version
ChromeDriver 123.0.6312.105 (399174dbe6eff0f59de9a6096129c0c827002b3a-refs/branch-heads/6312@{#761})

When I tried to rune test3.side with selenium-side-runner I got error as below

C:\Users\jack.chuong\Downloads>selenium-side-runner test3.side
info: Running test test3
 FAIL  ../AppData/Roaming/npm/node_modules/selenium-side-runner/dist/main.test.js (61.544 s)
  Running project test3
    Running suite Default Suite
      × Running test test3 (60022 ms)

  ● Running project test3 › Running suite Default Suite › Running test test3

    thrown: "Exceeded timeout of 60000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      at node_modules/jest-each/build/bind.js:47:15
          at Array.forEach (<anonymous>)
      at src/main.test.ts:174:11
          at Array.forEach (<anonymous>)
      at src/main.test.ts:161:22
          at Array.forEach (<anonymous>)
      at Object.<anonymous> (src/main.test.ts:134:18)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        61.713 s
Ran all test suites within paths "C:\Users\jack.chuong\AppData\Roaming\npm\node_modules\selenium-side-runner\dist\main.test.js".

Please give me some advice, thank you very much.

toddtarsi commented 2 months ago

@jackchuong - No harm at all in raising an issue here, thanks for doing so!

In this case, I think you probably want to use selenium-side-runner --help to review the CLI options. There are some very useful ones (-z is a favorite of mine). In this case, I think you're looking at setting the -T or --jest-timeout option

jackchuong commented 2 months ago

@toddtarsi thank you for your suggestion I print as much information as possible here:

C:\Users\jack.chuong\Downloads>selenium-side-runner -z failed -XdD -T 120000 -t 60000 test3.side
Configuration: {
  baseUrl: '',
  capabilities: { browserName: 'chrome' },
  debug: true,
  debugConnectionMode: true,
  debugStartup: true,
  filter: '.*',
  force: undefined,
  maxWorkers: 8,
  screenshotFailureDirectory: 'failed',
  projects: [ 'C:\\Users\\jack.chuong\\Downloads\\test3.side' ],
  proxyOptions: {},
  proxyType: undefined,
  retries: 0,
  runId: '5b30d2cb4eb60c1f3afe0304b12d7740',
  path: 'C:\\Users\\jack.chuong\\AppData\\Roaming\\npm\\node_modules\\',
  server: '',
  jestTimeout: 120000,
  timeout: 60000
}

  console.log
    Beginning test session

      at Object.<anonymous>.exports.default (src/connect.ts:9:11)

  console.info
    Building driver for chrome

      at WebDriverExecutor.getDriverSync (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:172:14)

  console.info
    Driver attributes:{ capabilities: {}, server: '', browserName: 'chrome' }

      at WebDriverExecutor.getDriverSync (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:173:14)

 FAIL  ../AppData/Roaming/npm/node_modules/selenium-side-runner/dist/main.test.js (121.124 s)
  × Testing driver connection (120012 ms)

  ● Testing driver connection

    thrown: "Exceeded timeout of 120000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      at Object.<anonymous> (src/main.test.ts:129:3)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        121.238 s
Ran all test suites within paths "C:\Users\jack.chuong\AppData\Roaming\npm\node_modules\selenium-side-runner\dist\main.test.js".

The "failed" folder is empty, the -T or --jest-timeout option doesn't help much, even though I set the timeout to 2 minutes or longer, I still get same error, I think timeout is not the reason , nn fact, my recording for test3.side was only 10 seconds long .

toddtarsi commented 2 months ago

Thank you for explaining. I'm sorry to lead you on such a wild goose chase. I deleted some of your config because I just don't like other peoples env stuff being out there. I think I'll take that line out of the config, or maybe at least add a whitelist. Sounds like something is failing to report well. I believe there is an issue with the initial connection. There is a "debug connection mode". Try this command:

selenium-side-runner -X test3.side

Basically, this attempts to connect to a chromedriver session at all, and if it has any issues, it means that there is something wrong with how its trying to find the chromedriver server or similar. If it doesn't have any issues, I am not sure whats happening here but its definitely in the IDE code fully.

jackchuong commented 2 months ago

I tried same step on other machine Windows 11 , same error , so there is nothing I can do ? Is anyone having the same problem as me?

toddtarsi commented 2 months ago

@jackchuong - This error is basically the reason the '-X' option exists. if you're hitting this and it's still failing, it should be giving you a really rich error. I just pushed a small increment that adds some 30 second abort messaging to the UX and offers next steps. Can you try coming up to the latest version of the runner and trying that command again?

toddtarsi commented 2 months ago

Oh! Also, do it like this in case you get any extra info:

NODE_DEBUG="*" selenium-side-runner -X your-file.side

jackchuong commented 2 months ago

@toddtarsi I updated selenium-side-runner and this is output

C:\Users\jack.chuong\Downloads>selenium-side-runner --version
4.0.5

C:\Users\jack.chuong\Downloads>set NODE_DEBUG="*"

C:\Users\jack.chuong\Downloads>selenium-side-runner -X test3.side
  console.log
    Beginning test session

      at Object.<anonymous>.exports.default (src/connect.ts:9:11)

  console.info
    Building driver for chrome

      at WebDriverExecutor.getDriverSync (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:172:14)

  console.info
    Driver attributes:{ capabilities: {}, server: '', browserName: 'chrome' }

      at WebDriverExecutor.getDriverSync (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:173:14)

  console.error

              Failed to build driver for chrome
              Supplied capabilities: {}
              Server: none
              Error: Error: Driver took too long to build. This is likely an issue with the browser or driver.

              OS: win32
              Node: v20.12.2
              Selenium-Webdriver: 4.19.0

              This is breaking at the boundary of the following code in selenium-webdriver:

              // BEGIN SELENIUM-WEBDRIVER CODE
              const webdriver = require('selenium-webdriver')
              const driver = new webdriver.Builder().withCapabilities({}).forBrowser('chrome').build()
              // END SELENIUM-WEBDRIVER CODE

              To ensure the bug is in selenium IDE, please attempt to run the above code in a script or node REPL.
              You may have to npm install selenium-webdriver first.

              If you are unable to proceed further, please raise a bug here:
              https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=I-defect%2Cneeds-triaging&projects=&template=bug-report.yml&title=%5B%F0%9F%90%9B+Bug%5D%3A+

              If this code works in selenium-webdriver, but not the IDE or side-runner, please raise a bug here:
              https://github.com/SeleniumHQ/selenium-ide/issues/new?assignees=&labels=&projects=&template=bug.md

      at WebDriverExecutor.getDriver (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:216:17)
      at WebDriverExecutor.init (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:259:21)
      at Object.<anonymous>.exports.default (src/connect.ts:10:3)
      at Object.<anonymous> (src/main.test.ts:130:5)

 FAIL  ../AppData/Roaming/npm/node_modules/selenium-side-runner/dist/main.test.js (31.198 s)
  × Testing driver connection (30134 ms)

  ● Testing driver connection

    Driver took too long to build. This is likely an issue with the browser or driver.

      at Timeout._onTimeout (node_modules/@seleniumhq/side-runtime/src/webdriver.ts:200:13)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        31.325 s, estimated 63 s
Ran all test suites within paths "C:\Users\jack.chuong\AppData\Roaming\npm\node_modules\selenium-side-runner\dist\main.test.js".
toddtarsi commented 2 months ago

@jackchuong - Perfect! Yep, follow those instructions and raise an issue wherever needed.