SeleniumHQ / selenium-ide

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

[selenium-side-runner] "wait for element visible" not waiting #1197

Closed tristanlins closed 1 year ago

tristanlins commented 3 years ago

🐛 Bug Report

A "wait for element visible" command does not wait, when executed with the selenium-side-runner.

To Reproduce

Running the Test Wait.side in Selenium IDE works fine. Running with selenium-side-runner fails.

$ selenium-side-runner "Test Wait.side"
info:    Running Test Wait.side
 FAIL  ./DefaultSuite.test.js
  Default Suite
    ✕ Test Wait (1268ms)

  ● Default Suite › Test Wait

    NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"#consent_prompt_submit"}
      (Session info: chrome=88.0.4324.150)

      3 | tests["Test Wait"] = async (driver, vars, opts = {}) => {
      4 |   await driver.get((new URL(`/start`, BASE_URL)).href);
    > 5 |   await driver.wait(until.elementIsVisible(await driver.findElement(By.css(`#consent_prompt_submit`))), 30000);
        |                                            ^
      6 | }
      7 | module.exports = tests;

      at Object.throwDecodedError (../../.config/yarn/global/node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (../../.config/yarn/global/node_modules/selenium-webdriver/lib/http.js:560:13)
      at Executor.execute (../../.config/yarn/global/node_modules/selenium-webdriver/lib/http.js:486:26)
      at Driver.execute (../../.config/yarn/global/node_modules/selenium-webdriver/lib/webdriver.js:699:17)
      at Object.<anonymous>.tests.Test Wait (commons.js:5:44)
      at Object.<anonymous> (DefaultSuite.test.js:11:5)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        2.484s
Ran all test suites.

Expected behavior

I'm not familiar with the selenium javascript api. But compared to the java api, this command:

await driver.wait(until.elementIsVisible(await driver.findElement(By.css(`#consent_prompt_submit`))), 30000);

is wrong. It should be

await driver.wait(until.elementIsVisible(By.css(`#consent_prompt_submit`)), 30000);

Project file reproducing this issue (highly encouraged)

Test Wait.zip

Environment

OS: Fedora 32 Selenium IDE Version: v3.17.0 Selenium SIDE Runner Version: 3.17.0 Node version: v14.15.3 Browser: Firefox Browser Version: 85

Baylibrejmonnet commented 3 years ago

i"ve the same issue when in run *.side with selnium-side-runner

florianwgnr commented 3 years ago

Can confirm this issue: "wait for element visible" only works within the IDE but crashes when run by SIDE Runner. "wait for element present" works fine.

j-applese3d commented 2 years ago

Did anyone find a workaround to this? I seem to be having the same problem, albeit it's running

await driver.wait(until.elementLocated(By.id(`accordionPersonalSavedReportAnchor`)), configuration.timeout);

for me... I tried changing the .suites[0].timeout to something giant, but it doesn't seem to have any effect.

Here's the error:

    ElementNotInteractableError: element not interactable
      (Session info: chrome=105.0.5195.102)

      43 |   });
      44 |   await driver.wait(until.elementLocated(By.id(`accordionPersonalSavedReportAnchor`)), configuration.timeout);
    > 45 |   await driver.findElement(By.id(`accordionPersonalSavedReportAnchor`)).then(element => {
         |   ^
      46 |     return element.click();
      47 |   });
      48 |   await driver.wait(until.elementLocated(By.linkText(`otherButton`)), configuration.timeout);

      at Object.throwDecodedError (../../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (../../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:560:13)
      at Executor.execute (../../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:486:26)
      at Driver.execute (../../../usr/lib/node_modules/selenium-side-runner/node_modules/selenium-webdriver/lib/webdriver.js:699:17)
      at Object.<anonymous>.tests.Test1 (commons.js:45:3)
      at Object.<anonymous> (DefaultSuite.test.js:11:5)
toddtarsi commented 2 years ago

@j-applese3d - So, v3 is gonna get a store takedown in like 3 months anyway. I'd recommend trying v4 of the side runner

npm package: @seleniumhq/side-runner

Things work much better there. All and all I'd advocate for doing the following long term if you like using an IDE:

  1. Try Nightwatch.js with the chrome recorder extension. This is actually funded by Browserstack or Sauce labs or one of em. Basically, it's not fueled by 100% burnout and actually automates browsers correctly.
  2. Try out cypress.io - these guys suck at automating browsers (alert handling and similar is borked) but they're good at making a hell of a responsive IDE.
  3. Try v4 of the IDE - I put this one last because I am open source burnout incarnate. I don't make any money off maintaining this software and the loudest voices in Selenium / SFC are code purists who would probably throw a party if the whole IDE fell into the ocean.
toddtarsi commented 2 years ago

Oh, here's where you can download v4 of the IDE if you'd like:

https://github.com/SeleniumHQ/selenium-ide/releases/tag/4.0.0-alpha.3

It's still in Alpha, much is broken, and I generally only fix things if someone actually really cares about v4 of the IDE and they raise an issue here.

toddtarsi commented 2 years ago

I should also mention that I do use it for work. I find the recording / playback and side-runner are really good for me, but I am not everyone. Just expect some jenk if you go for it.

toddtarsi commented 2 years ago

Oh also, yes I don't have code signing certificates so it will say the developer is untrusted. To get those, I'd have to get a signature from somewhere in Selenium or the SFC. It may happen one day, but probably not as it would require acknowledgement that v4 of the IDE exists.

The binaries are generated using a fully automated process that is written here:

https://github.com/SeleniumHQ/selenium-ide/blob/trunk/.github/workflows/release.yml

toddtarsi commented 1 year ago

Closing this, as wait for element visible is working pretty well as expected in v4

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.