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]: v9: Deprecated function expect(...).toHaveTextContaining(...) used in the sample WDIO project #13413

Closed
3 tasks done
giuseppe-salvatore opened this issue Aug 19, 2024 · 7 comments
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested

Comments

@giuseppe-salvatore
Copy link
Contributor

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

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

Is there an existing issue for this?

  • I have searched the existing issues
@giuseppe-salvatore giuseppe-salvatore added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Aug 19, 2024
@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Aug 19, 2024
@giuseppe-salvatore
Copy link
Contributor Author

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

giuseppe-salvatore added a commit to giuseppe-salvatore/webdriverio that referenced this issue Aug 19, 2024
…13413)

Execution of newly created project using the config wizard reports
an error due to the usage of toHaveTextContaining() function.

This fix replaces it with toContain() called on a string.
@giuseppe-salvatore
Copy link
Contributor Author

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

@giuseppe-salvatore
Copy link
Contributor Author

#13416

@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!

christian-bromann pushed a commit that referenced this issue Aug 19, 2024
)

* fix(webdriverio): issue generating sample project on V9  (#13413)

Execution of newly created project using the config wizard reports
an error due to the usage of toHaveTextContaining() function.

This fix replaces it with toContain() called on a string.

* Addressed PR comments
@giuseppe-salvatore
Copy link
Contributor Author

Fixed with #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
Copy link
Member

@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 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

4 participants