webdriverio / webdriverio

Next-gen browser and mobile automation test framework for Node.js
http://webdriver.io
MIT License
8.99k stars 2.49k forks source link

[šŸ› Bug]: v9: Deprecated function expect(...).toHaveTextContaining(...) used in the sample WDIO project #13413

Closed giuseppe-salvatore closed 1 month ago

giuseppe-salvatore commented 1 month ago

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.0.4

Node.js Version

22.6

Mode

Standalone Mode

Which capabilities are you using?

{
   browser: "chrome"
}

What happened?

Selecting cucumber/typescript from the config wizard results in generation of broken code. That's because the function toHaveTextContaining has been removed.

I found this works

await expect(await SecurePage.flashAlert.getText()).toContain(message);

What is your expected behavior?

Initialisation and execution of the sample should complete with success (assuming the target website does't have any issues)

How to reproduce the bug.

yarn create wdio .

Select the following config

? A project named "webdriverio-autoinit" was detected at "/home/workspace/webdriver.io/webdriverio-autoinit", correct? yes ? What type of testing would you like to do? E2E Testing - of Web or Mobile Applications ? Where is your automation backend located? On my local machine ? Which environment you would like to automate? Web - web applications in the browser ? With which browser should we start? ? Which framework do you want to use? Cucumber (https://cucumber.io/) ? Do you want to use Typescript to write tests? yes ? Do you want WebdriverIO to autogenerate some test files? yes ? What should be the location of your feature files? /home/workspace/webdriver.io/webdriverio-autoinit/features/*/.feature ? What should be the location of your step definitions? /home/workspace/webdriver.io/webdriverio-autoinit/features/step-definitions/steps.ts ? Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? yes ? Where are your page objects located? /home/workspace/webdriver.io/webdriverio-autoinit/features/pageobjects/*/.ts ? Which reporter do you want to use? ? Do you want to add a plugin to your test setup? ? Would you like to include Visual Testing to your setup? For more information see https://webdriver.io/docs/visual-testing! no ? Do you want to add a service to your test setup? ? Do you want me to run npm install no

Then run

yarn wdio

Relevant log output

[0-0] 2024-08-19T13:38:43.106Z INFO webdriver: BIDI COMMAND browsingContext.locateNodes {"locator":{"type":"css","value":"#flash"},"context":"348AE8B320913E4534FCBE802825C56D"}
[0-0] 2024-08-19T13:38:43.110Z INFO webdriver: COMMAND getWindowHandle()
[0-0] 2024-08-19T13:38:43.110Z INFO webdriver: [GET] http://localhost:46631/session/3e209239711369329126a3a8143ab35f/window
[0-0] Error in "1: Then I should see a flash message saying Your username is invalid!"

TypeError: expect(...).toHaveTextContaining is not a function
    at World.<anonymous> (/home/workspace/webdriver.io/9.0.4/features/step-definitions/steps.ts:21:41)

[0-0] 2024-08-19T13:38:43.111Z INFO webdriver: COMMAND deleteSession()
[0-0] 2024-08-19T13:38:43.111Z INFO webdriver: [DELETE] http://localhost:46631/session/3e209239711369329126a3a8143ab35f
[0-0] 2024-08-19T13:38:43.112Z INFO webdriver: RESULT 348AE8B320913E4534FCBE802825C56D
[0-0] 2024-08-19T13:38:43.112Z INFO webdriver: BIDI COMMAND browsingContext.locateNodes {"locator":{"type":"css","value":"#flash"},"context":"348AE8B320913E4534FCBE802825C56D"}
[0-0] 2024-08-19T13:38:43.163Z INFO webdriver: RESULT null
[0-0] 2024-08-19T13:38:43.163Z INFO webdriver: Kill driver process with PID 49899
[0-0] FAILED in chrome - file:///features/login.feature
2024-08-19T13:38:43.281Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2024-08-19T13:38:43.282Z INFO @wdio/cli:launcher: Run onComplete hook

Spec Files:  0 passed, 1 failed, 1 total (100% completed) in 00:00:03  

2024-08-19T13:38:43.282Z INFO @wdio/local-runner: Shutting down spawned worker
2024-08-19T13:38:43.533Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2024-08-19T13:38:43.533Z INFO @wdio/local-runner: shutting down
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Code of Conduct

Is there an existing issue for this?

giuseppe-salvatore commented 1 month ago

@christian-bromann I have a simple fix and a branch I can push, ready to raise a PR, but I don't have permissions

BorisOsipov commented 1 month ago

@giuseppe-salvatore https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

giuseppe-salvatore commented 1 month ago

thanks @BorisOsipov will do my best, first contribution to OS project :smiley:

giuseppe-salvatore commented 1 month ago

https://github.com/webdriverio/webdriverio/pull/13416

wdio-bot commented 1 month ago

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!

giuseppe-salvatore commented 1 month ago

Fixed with https://github.com/webdriverio/webdriverio/pull/13416. Although I tested it locally I want to see what happens after the config wizard setup, happy to close it as soon as this passes

BorisOsipov commented 1 month ago

@giuseppe-salvatore Congratulations on your first PR!

Tips: You can write "fixes #13413" or "closes #13413" in the PR text description, where 13413 is the issue number, and when the PR is merged, Github will automatically close the linked issue šŸ˜ƒ