🎯 Key Takeaways for quick navigation: 00:00 📚 The video is a tutorial on creating a WebdriverIO Cucumber BDD project from scratch. 01:10 📝 BDD (Behavior Driven Development) is a process where test cases, scenarios, and user stories are written in simple English-like language, making it understandable by every team in the organization. 06:22 ⚙️ To set up a WebdriverIO Cucumber BDD framework, create a folder, open it in VS Code, initialize a Node project using `npm init`, and run `npx wdio init` to set up the project with Cucumber framework and other configurations. 12:54 🔗 Use VS Code extensions or keyboard shortcuts to navigate between feature files and step definitions, making it easier to manage and implement the scenarios. 18:49 🛠️ Implement step definitions for each step in the feature file to link the scenario steps with actual automation code. 24:35 ✅ Verify the setup and steps by running the test scenarios to ensure everything is working correctly. 25:35 📝 The tutorial covers using async and await with WebdriverIO code commands. 27:26 📝 Locator strategies (hash for ID, dot for class) are used to find elements in WebdriverIO tests. 29:07 📝 The expect library in WebdriverIO is demonstrated to check various conditions (text, attributes, etc.) on elements. 32:45 📝 Parameterization is used to create reusable scenarios with multiple sets of data in WebdriverIO Cucumber BDD tests. 35:18 📝 Regular expressions (regex) are used in step definitions to match dynamic data in feature files. 41:15 📝 Scenario outline is used to parameterize scenarios with examples section, allowing multiple test cases. 43:41 📝 Page Object Model (POM) can be implemented to organize code and improve maintainability in WebdriverIO tests. 44:38 📝 WebdriverIO supports various types of reports, such as Leo, Concise, JUnit, Spec, HTML, Cucumber JSON, Mocha, and Awesome. Made with HARPA AI
@RaghavPal Жыл бұрын
Thanks for adding timestamps Sai
@xXMrThomasXx6 ай бұрын
I really like your approach to learning. Thx for all course and now I can start training this topic :)
@RaghavPal6 ай бұрын
Most welcome
@MsGomathyАй бұрын
Appreciate the detailed session, very helpful. Suggest me which approach i can follow to test multiple language sites ex: in the url path english, spanish, german etc..
@RaghavPalАй бұрын
Gomathy To test multiple language sites in WebdriverIO, follow these approaches: Parameterized Test Cases: Use test.each or a similar data-driven approach to pass language codes dynamically to your test cases. Example: javascript const languages = ['en', 'es', 'de']; languages.forEach(lang => { it(`should test site in ${lang}`, async () => { await browser.url(`example.com/${lang}`); // Add validation for the language-specific content. }); }); Environment Variables: Use environment variables to switch languages at runtime: LANG=en npx wdio run wdio.conf.js Access process.env.LANG in the test to construct URLs dynamically. Custom Test Data File: Maintain a JSON file with URL paths or specific translations for each language. Load this file into your tests to verify content. Page Object Model (POM): In the POM, pass the language dynamically to the methods handling navigation or validations: class HomePage { open(lang) { return browser.url(`example.com/${lang}`); } } Choose based on scalability and team preference -
@minakshifarakate2673 Жыл бұрын
Thanks Ragav for this series..I would like to request you add more video on how to handling windows pop-up which are coming while downloading any file, how to read and write excel ,, api testing using wdio
@RaghavPal Жыл бұрын
Sure I will do Minakshi
@Parry-cb2eb Жыл бұрын
Appreciate the detailed session, very helpful. Is it possible to create something around visual testing? like Percy & web driver io
@RaghavPal Жыл бұрын
I will plan on this Parry
@robertrobles769810 ай бұрын
Great tutorial, how do you setup code coverage using webdriverio & cucumber?
@RaghavPal10 ай бұрын
Thanks Robert Let's explore how to set up code coverage using WebDriverIO with Cucumber: 1. Enable Code Coverage in WebDriverIO: - WebDriverIO provides a way to capture code coverage of your JavaScript application files. - To enable code coverage reporting, follow these steps: - In your `wdio.conf.js` (WebDriverIO configuration file), add the following settings: ```javascript export const config = { // Other configuration options... runner: ['browser', { preset: process.env.WDIO_PRESET, coverage: { enabled: true, // Enable code coverage // Other coverage-related options (e.g., reporters, thresholds) can be configured here }, // Other browser runner options... }], }; ``` - Set `enabled: true` to enable code coverage. 2. Instrument Your Source Code: - Use a popular instrumentation tool like Istanbul to instrument your development source code. - Instrumentation adds tracking code to your source files to collect coverage data during execution. 3. Serve the Instrumented Source Code: - Serve the instrumented source code on your local machine. - You can use a local server or any other method to make the instrumented code accessible. 4. Run E2E Tests Against the Instrumented Source Code: - Execute your end-to-end (E2E) tests using WebDriverIO and Cucumber. - Since the source code is instrumented, the tests will collect coverage data during execution. 5. Generate Code Coverage Report: - After running the tests, a code coverage report will be generated. - You can analyze this report to identify areas where you need more E2E tests or where code coverage is lacking. Remember to adjust the configuration and paths according to your project structure. By integrating WebDriverIO with Cucumber and enabling code coverage, you'll have better insights into your test coverage All the best..
@robertrobles769810 ай бұрын
@@RaghavPal Thanks will try this 😎
@roblesrt10 ай бұрын
Sorry I forgot to mention I am using webdriverio v7, will this configuration still work? or it is only applicable to v8?
@roblesrt10 ай бұрын
@@RaghavPal I tried this but I got this error message: Error: Currently only "mocha" is supported as framework when using @wdio/browser-runner.
@RaghavPal10 ай бұрын
The error message you're encountering indicates that the @wdio/browser-runner currently supports only the Mocha testing framework. If you're trying to use a different testing framework (such as Jest or Jasmine), you'll need to make some adjustments. Here's how to proceed: 1. Check Your Configuration: - Ensure that your WebdriverIO configuration (usually in a `wdio.conf.js` file) specifies the correct testing framework. - Look for a line like this in your configuration: ```javascript framework: 'mocha', // or 'jasmine', 'jest', etc. ``` - If it's set to something other than 'mocha', update it to use 'mocha'. 2. Install Mocha: - If you haven't already, make sure you have Mocha installed as a dependency in your project: ``` npm install mocha --save-dev ``` 3. Run Your Tests: - Now try running your tests again using the Mocha framework: ``` npx wdio run wdio.conf.js ``` 4. Framework-Specific Adjustments: - If you were previously using a different framework (e.g., Jest), you might need to adjust your test files or configuration to align with Mocha conventions. - For example, Mocha uses `describe`, `it`, and `before/after` hooks. Make sure your test files follow this structure. 5. Check Dependencies: - Verify that your project's dependencies (including WebdriverIO) are up to date. - Run `npm outdated` to check for outdated packages and update them if necessary. 6. Custom Frameworks: - If you have a custom testing framework, you'll need to create a custom adapter for @wdio/browser-runner to support it. - Refer to the official WebdriverIO documentation for guidance on creating custom adapters. .
@vishwasvishwas724 күн бұрын
Hi Raghav, why am i getting an additional tab opened...BiDi cdp manager. Is there a way to avoid it?
@RaghavPal23 күн бұрын
Vishwas An additional tab may open in a WebdriverIO with Cucumber project due to links or actions in your tests that trigger new tab behavior, such as clicking on links that are set to open in a new tab. To avoid this, you can: Modify the Application Behavior: If the application you are testing has links that open in new tabs, consider modifying the application code to prevent this behavior during testing. This can often be done by removing the target="_blank" attribute from links Use Browser Commands: You can switch to the newly opened tab and close it immediately after performing the necessary actions. Use the following commands: javascript const handles = await browser.getWindowHandles(); await browser.switchToWindow(handles[handles.length - 1]); // Switch to the new tab await browser.closeWindow(); // Close the new tab await browser.switchToWindow(handles[0]); // Switch back to the original tab Disable Pop-ups: Ensure that your browser settings or WebDriver capabilities are configured to disable pop-ups, which can help prevent additional tabs from opening. Check for BiDi CDP Manager: If the BiDi CDP manager is causing the additional tab, ensure that your WebDriverIO configuration is set up correctly. You may want to check the version compatibility of WebDriverIO and the browser you are using. Use Headless Mode: Running your tests in headless mode can sometimes prevent additional tabs from opening, as the browser does not render a UI. By implementing these strategies, you should be able to minimize or eliminate the occurrence of additional tabs opening during your WebdriverIO tests -
@rumpelshtilcken22396 ай бұрын
Thank you, Raghav, as always you explain everything wonderfully! Will there be a video on WDIO and mobile?
@RaghavPal6 ай бұрын
Most welcome Rumpel. I will plan.. you can check all existing videos here - automationstepbystep.com/
@rumpelshtilcken22396 ай бұрын
@@RaghavPal Thank you, Raghav! I will be waiting eagerly. You explain things very well!
@maithichun10 ай бұрын
Hi Raghav, Can you please suggest why are yellow lines not displayed in feature file even after adding cucumber extension. Also not able to navigate from feature to step defintion on right click .Thanks
@RaghavPal10 ай бұрын
Maithi Let's address the issues related to WebdriverIO and Cucumber integration in your BDD project. 1. Yellow Lines (Step Highlighting) in Feature Files: - To enable yellow lines (step highlighting) in your feature files, follow these steps: 1. Install Cucumber (Gherkin) Full Support Extension: - Open VS Code. - Go to the Extensions view by clicking on the square icon on the sidebar or using the shortcut `Ctrl+Shift+X`. - Search for "Cucumber (Gherkin) Full Support" and install it. 2. Reload VS Code after installing the extension. 3. Now, open your feature file, and you should see the yellow highlighting for Gherkin steps. 2. Step Navigation from Feature to Step Definitions: - To navigate from a step in the feature file to its corresponding step definition: - Open your feature file. - Place the cursor on the step you want to navigate. - Use the shortcut `Ctrl+Click` (or `Cmd+Click` on macOS) on the step. - VS Code should take you to the corresponding step definition in your step definition file. 3. Additional Tips: - Ensure that your project structure adheres to the standard layout (e.g., `src/test/java` for step definitions). - Verify that your step definitions are correctly linked to the feature file steps. - Double-check the compatibility of the installed extensions with your VS Code version. Remember to verify the installation of the Cucumber (Gherkin) Full Support extension, and ensure that your project setup aligns with the expected structure. ..
@shyamalaS-x1f Жыл бұрын
@RaghavPal while setting up project i havent got chromedriver option for the question do you want to add service to your project? kindly suggest what have to do
@RaghavPal Жыл бұрын
Hi Shyamala May be some changes in new ver. Can go as per the options you have, Can also check some latest examples online
@prashanthis1117 Жыл бұрын
Thanks for the clear explanation 👏 My question: I need to use cucumber in webdriverIO - component testing. I'm not able to get cucumber option while installing, can you please help me sir?🙏
@RaghavPal Жыл бұрын
Prashanthi To use Cucumber in WebdriverIO component testing, you need to install the WebdriverIO cucumber plugin. **To install the WebdriverIO cucumber plugin:** ``` npm install webdriverio-cucumber-js ``` Once the plugin is installed, you need to create a cucumber feature file. Feature files are used to define the scenarios that you want to test. Here is an example of a cucumber feature file: ``` Feature: Component Testing Scenario: Verify that the button is displayed Given I am on the login page When I click on the login button Then the login form is displayed ``` To run the cucumber tests, you can use the following command: ``` npx cucumber ``` This will start the cucumber test runner and execute the tests in the feature file. **To use the WebdriverIO cucumber plugin for component testing:** 1. Create a new WebdriverIO test suite. 2. In the test suite, add the following code: ``` import cucumberjs from 'webdriverio-cucumber-js'; const suite = new cucumberjs.TestSuite('Component Testing'); suite.addFile('features/component-testing.feature'); suite.run(); ``` 3. Run the test suite using the following command: ``` npx wdio ``` This will start the WebdriverIO test runner and execute the cucumber tests in the feature file. The WebdriverIO cucumber plugin will use the WebdriverIO API to interact with the web application and to perform the tests that are defined in the feature file. **Troubleshooting** If you are not able to see the cucumber option while installing WebdriverIO, it may be because you are using an older version of WebdriverIO. The cucumber option was added in WebdriverIO version 7.0.0. To update WebdriverIO to version 7.0.0, run the following command: ``` npm install webdriverio@7.0.0 ``` Once WebdriverIO is updated, you should be able to see the cucumber option while installing.
@awadhnarayansingh96299 ай бұрын
Very informative! Thank you Sir. I have a question on Wdio cucumber. Is there an efficient way to pass data between steps (same steps file) in cucumber. My framework is build on wdio, cucumber with JavaScript and using VSCode as editor. Also, if I'm calling steps from different step files in my Scenario (in feature file), how to pass data between steps in this case?
@RaghavPal9 ай бұрын
Awadh In Cucumber (including Cucumber-JS), passing data between steps is essential for maintaining context and sharing information. Let's explore efficient ways to achieve this: 1. Scenario Context (Scenario-Specific Data): - Scenario Context allows you to share data within the same scenario. It's a built-in feature in Cucumber-JS. - Here's how you can use it: 1. Design a Scenario Context class (usually an enum or a plain object) to store shared data. For example: ```javascript // context.js const { setWorldConstructor } = require('cucumber'); class MyScenarioContext { constructor() { this.productName = null; // Add other shared properties if needed } } setWorldConstructor(MyScenarioContext); ``` 2. Save test information/data/state in the Scenario Context: - In your step definitions, you can access and modify the shared properties: ```javascript // step_definitions.js const { Given, When, Then } = require('cucumber'); Given('User creation form management', function () { this.productName = 'Stackoverflow'; // Save data to the context }); When(/^I have (\d+) (.*) in my basket$/, function (number, veg) { // Use this.productName and other shared properties // ... }); ``` - Advantages: - Isolated to the current scenario. - No leakage of shared state between scenarios. 2. Dependency Injection (DI): - Use DI containers to manage shared dependencies across step definitions. - Cucumber-JS supports various DI containers (e.g., PicoContainer, Guice, Spring). - Example using PicoContainer: ```javascript // MySharedData.js class MySharedData { constructor() { this.stringData = null; } } // SomeStepDefs.js class SomeStepDefs { constructor(sharedData) { this.sharedData = sharedData; } // Other step definitions... } // MoreStepDefs.js class MoreStepDefs { constructor(sharedData) { this.sharedData = sharedData; } // Other step definitions... } ``` - Advantages: - Dependency injection ensures fresh instances for each scenario. - No shared state leakage between scenarios. 3. Calling Steps from Different Step Files: - When calling steps from different files, you can still use the same approaches mentioned above. - The shared data (context or DI) will be available across step files as long as they belong to the same scenario. Remember to choose the approach that best fits your framework and use case. Both Scenario Context and DI provide efficient ways to pass data between steps in Cucumber-JS. ..
@awadhnarayansingh96299 ай бұрын
Hello @@RaghavPal sir. Thank you for quick information on problem solution. I'm going to try scenario context. Thanks a lot.
@WhyIsTheRumAlwysGoneАй бұрын
Thank you Raghav for this. Doesn't wdio require explicit glue like Java ? How does the compiler know where is the step definition located ? Is this from wdio.conf.js - cucumberOpts - require ?
@RaghavPalАй бұрын
Sagar In WebDriverIO with Cucumber: cucumberOpts.require in wdio.conf.js specifies where the step definition files are located. Example: js cucumberOpts: { require: ['./tests/step-definitions/*.js'], } The step definitions file contains the logic for each step (e.g., Given, When, Then). Example: js const { Given, When, Then } = require('@cucumber/cucumber'); Given('I open the homepage', () => { browser.url('example.com'); }); Cucumber uses this require setting to link the steps to their definitions -
@WhyIsTheRumAlwysGoneАй бұрын
@RaghavPal Thank you 👍🏽 for the clarification. One thing on the second snippet you posted here, the line const-given-when-then - does it serve as kind of importing cucumber keywords ? I know I should not fight the syntax but was just curious.
@RaghavPalАй бұрын
To use Given, When, and Then in WebDriverIO with Cucumber: Install dependencies: npm install @cucumber/cucumber @wdio/cucumber-framework --save-dev Import in your step definition: javascript const { Given, When, Then } = require('@cucumber/cucumber'); Now you can use Given, When, and Then in your tests -
@WhyIsTheRumAlwysGoneАй бұрын
@@RaghavPal Thank you. This was very helpful.
@navidhoque4625 Жыл бұрын
I was wondering what would i be doing wrong because every time i try to run the test the then statement of the test is aways being skipped and i double checked to make sure i followed you exactly and it still keeps getting skipped
@RaghavPal Жыл бұрын
Hi Navid, If the then statement of your WebdriverIO test is being skipped, there could be several possible reasons for this. Here are a few things to check: Make sure that the then statement is actually being executed. If the previous step in the test fails, then the then statement will be skipped. You can use the browser.debug() command to pause the test and inspect the current state of the browser. Check that the then statement is correctly chained to the preceding expect or assert statement. The then statement should be executed after the preceding statement has completed. Verify that the then statement contains the correct code to perform the desired action. If there is a mistake in the code, the then statement may not execute as expected. Ensure that the then statement is not being skipped due to a race condition. For example, if the then statement depends on an asynchronous operation, like waiting for an element to become visible, there may be a delay before the then statement can execute. If none of these suggestions solve the issue, please provide more details about your specific test case and the code you are using so that I can provide more targeted assistance.
@agustinandres6451 Жыл бұрын
Hello. Is it possible to run several scenarios using Cucumber + Appium + WDIO? The second scenario starts running after the last step of the previous scenario. I think I should do a cleanup using afterScenario(), but I'm not sure how to do it.
@RaghavPal Жыл бұрын
Yes, it is possible to run several scenarios using Cucumber + Appium + WDIO. By default, Cucumber runs each scenario in isolation, so you should not have any issues with the second scenario starting after the last step of the previous scenario. However, if you do have issues with leftover state from the previous scenario affecting the next one, you can use hooks to perform cleanup actions. In Cucumber, you can define hooks that run before or after each scenario, or before or after each feature. To define an "after scenario" hook in Cucumber, you can use the following code: import io.cucumber.java.After; public class Hooks { @After public void afterScenario() { // Cleanup actions go here } } This code defines an "after scenario" hook that will run after each scenario. You can add whatever cleanup actions you need inside the hook. To use this hook in your Cucumber + Appium + WDIO setup, you can add it to the glue path in your Cucumber options. For example, if your hook code is in a package called "hooks" and your step definitions are in a package called "steps", you can use the following Cucumber options: @CucumberOptions( features = "path/to/your/features", glue = {"hooks", "steps"} ) With these options, Cucumber will scan both the "hooks" and "steps" packages for hooks and step definitions. Note that if you have multiple hooks defined in different classes, they will run in the order that they are defined in the glue path. If you need more control over the order in which hooks run, you can use the @Order annotation to specify the order explicitly
@agustinandres6451 Жыл бұрын
@@RaghavPal Thank you. This was the code I needed: afterScenario: async function (world, result, context) { await browser.closeApp(); await browser.reset(); },
@sonakumar71373 ай бұрын
Hi I am facing 2 error at the starting itself [ERROR webdriver: TypeError: Invalid URL] [ERROR @wdio/runner: Error: Failed to create session.]
@RaghavPal2 ай бұрын
Sona It looks like you're running into some issues with WebdriverIO right from the start. Let's break down the two errors you're seeing: Error 1: [ERROR webdriver: TypeError: Invalid URL] This error suggests that WebdriverIO is trying to access an invalid URL. This could be due to a misconfigured baseUrl or url property in your WebdriverIO configuration file. To troubleshoot this, can you please check your wdio.conf.js file and ensure that the baseUrl or url property is set correctly? For example, it should be in the format of localhost:8080 or example.com. Error 2: [ERROR @wdio/runner: Error: Failed to create session.] This error indicates that WebdriverIO is unable to create a new session. This could be due to various reasons such as: Incorrect browser configuration WebDriver executable not found Browser version incompatibility To troubleshoot this, can you please check the following: Ensure that you have the correct browser executable installed (e.g., ChromeDriver for Chrome) Verify that the browser version is compatible with the WebDriver version Check your wdio.conf.js file for any browser configuration issues Here's an example of a basic wdio.conf.js file: export.config = { // ... capabilities: [{ browserName: 'chrome', chromeOptions: { args: ['--headless', '--disable-gpu'] } }], // ... } -
@Colinh78sdizo Жыл бұрын
Hi Sir, thanks for the course and i have a question in my steps it throws an error when i use import { Given, When, Then } from '@wdio/cucumber-framework'; and works for const { Given, When, Then } = require('@wdio/cucumber-framework'); also i have tried adding type : module but it gives another error, please advice because my colleague on his side can use import with no issues.
@RaghavPal Жыл бұрын
Hi Colinh The issue you are facing might be related to the version of Node.js you are using. The import syntax is only available in ES6 modules, which are supported in Node.js from version 13.2 onwards. If you are using an older version of Node.js, you will need to use the require syntax instead. You can check the version of Node.js you are using by running the following command in your terminal: node -v If your version is older than 13.2, you can either upgrade Node.js to a newer version that supports ES6 modules or continue to use the require syntax. If you want to continue using the import syntax, you can add the following line to the top of your wdio.conf.js file: exports.config = { // ... type: 'module', // ... }; This tells Node.js to treat your JavaScript files as ES6 modules, allowing you to use the import syntax. However, please note that this might cause compatibility issues with other packages or modules that do not support ES6 modules. Once you have added the type: 'module' line to your wdio.conf.js file, you should be able to use the import syntax in your test files. If you are still facing issues, please let me know the exact error message you are getting, and I will try to assist you further.
@Colinh78sdizo Жыл бұрын
@@RaghavPal I am currently on v18.14.2 for node and will add the type : module line and see if it will help with my issue however you have mentioned that i might face compatibility issues with other packages.
@Colinh78sdizo Жыл бұрын
@@RaghavPal Hi Sir, i get the same error after including the type : mudule in the config file with the below error : DevTools listening on ws://127.0.0.1:50502/devtools/browser/2880fe9a-4332-4389-829d-b39166aad759 [0-0] (node:16856) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. [0-0] (Use `node --trace-warnings ...` to show where the warning was created) [0-0] 2023-04-24T06:59:42.804Z ERROR @wdio/runner: C:\work\git\j5TestAutomationCucumber\features\step-definitions\login.demo.steps.js:1 [0-0] import { Given, When, Then } from '@wdio/cucumber-framework'; [0-0] ^^^^^^ [0-0] [0-0] SyntaxError: Cannot use import statement outside a module [0-0] at internalCompileFunction (node:internal/vm:73:18) [0-0] at wrapSafe (node:internal/modules/cjs/loader:1176:20) [0-0] at Module._compile (node:internal/modules/cjs/loader:1218:27) [0-0] at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) [0-0] at Module.load (node:internal/modules/cjs/loader:1117:32) [0-0] at Module._load (node:internal/modules/cjs/loader:958:12) [0-0] at Function.hookedLoader [as _load] (C:\work\git\j5TestAutomationCucumber ode_modules\mockery\mockery.js:111:12) [0-0] at ModuleWrap. (node:internal/modules/esm/translators:169:29) [0-0] at ModuleJob.run (node:internal/modules/esm/module_job:194:25) [0-0] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) [0-0] Error: Cannot use import statement outside a module [0-0] 2023-04-24T06:59:42.814Z INFO webdriver: COMMAND deleteSession() [0-0] 2023-04-24T06:59:42.816Z INFO webdriver: [DELETE] localhost:9515/session/5371878a3cec0c6ae59fadaad534f44d [0-0] 2023-04-24T06:59:42.952Z INFO webdriver: RESULT null 2023-04-24T06:59:43.079Z DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1 [0-0] FAILED in chrome - file:///C:/work/git/j5TestAutomationCucumber/features/login.demo.feature 2023-04-24T06:59:43.080Z INFO @wdio/cli:launcher: Run onWorkerEnd hook 2023-04-24T06:59:43.081Z DEBUG @wdio/cli:utils: Finished to run "onWorkerEnd" hook in 0ms 2023-04-24T06:59:43.082Z INFO @wdio/cli:launcher: Run onComplete hook 2023-04-24T06:59:43.083Z DEBUG @wdio/cli:utils: Finished to run "onComplete" hook in 1ms Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:07
@RaghavPal Жыл бұрын
Yes, setting type: module in the package.json file can sometimes cause compatibility issues with other packages, especially those that were written with the require syntax in mind. This is because type: module uses the ES modules syntax which is relatively new in the Node.js ecosystem and not yet fully adopted by all packages. Some packages may have compatibility issues when using type: module. If you do encounter issues with other packages, you may need to switch back to using the require syntax, or find alternative packages that are compatible with ES modules.
@zuhairi-muhammad Жыл бұрын
hello sir, I've tried the tutorial but I got the following warnings: DeprecationWarning: `PickleFilter` is deprecated, use `loadSources` instead; DeprecationWarning: `parseGherkinMessageStream` is deprecated, use `loadSources` instead, and then my test is always skipped, could you please help me to solve this issue? thanks sir
@RaghavPal Жыл бұрын
The error messages you're seeing suggest that there are deprecation warnings related to the use of `PickleFilter` and `parseGherkinMessageStream` in your WebdriverIO project. These warnings indicate that these methods are deprecated and may be removed in future versions of WebdriverIO. You should update your code to use the recommended alternatives. Here's how you can address these deprecation warnings: 1. **Replace `PickleFilter`**: Instead of using `PickleFilter`, you should use the `loadSources` configuration option in your WebdriverIO configuration file (usually `wdio.conf.js`). Example `wdio.conf.js` configuration: ```javascript exports.config = { // ... cucumberOpts: { // ... // Replace PickleFilter with loadSources loadSources: () => { return [ // Add paths to your feature files here './path/to/your/feature/files/*.feature' ]; }, // ... }, // ... }; ``` 2. **Replace `parseGherkinMessageStream`**: Similar to `PickleFilter`, replace the usage of `parseGherkinMessageStream` with `loadSources` in your `wdio.conf.js` configuration. Example: ```javascript exports.config = { // ... cucumberOpts: { // ... // Replace parseGherkinMessageStream with loadSources loadSources: () => { return [ // Add paths to your feature files here './path/to/your/feature/files/*.feature' ]; }, // ... }, // ... }; ``` After making these changes, the deprecation warnings related to `PickleFilter` and `parseGherkinMessageStream` should no longer appear, and your WebdriverIO tests should continue to work as expected. Make sure to also check if you are using the latest version of WebdriverIO, as some of these deprecations might have been addressed in newer releases. Always refer to the official WebdriverIO documentation and release notes for the most up-to-date information on configuration and usage.
@abeenaa9869 Жыл бұрын
hi sir, when i tried to run the cmd : npx wdio --spec\feature\login.demo.feature; it run both feature extensions (login.feature and login.demo.feature). please assist
@RaghavPal Жыл бұрын
Hi Abeena, When running the command npx wdio --spec\feature\login.demo.feature, you are specifying a single feature file to run. However, if you have multiple feature files in your project that match the pattern **/*.feature, WebdriverIO will run all of them. To run only a specific feature file, you need to provide the exact path to that file. In your case, it sounds like you have two feature files that start with "login" and running the command with the path to the .demo file is not excluding the other file. One way to resolve this is to rename one of the feature files so that it does not start with "login". Alternatively, you can use a more specific path to the feature file you want to run. For example, if your project structure looks like this: . ├── features │ ├── login.feature │ └── login.demo.feature └── wdio.conf.js And you want to run only the login.demo.feature file, you can use the following command: npx wdio wdio.conf.js --spec ./features/login.demo.feature This command specifies the exact path to the feature file you want to run and should exclude the other login.feature file.
@abeenaa9869 Жыл бұрын
@@RaghavPal Thankyou sir.. expecting more videos. 🙂
@shreyasmandlik6354 Жыл бұрын
Hi Sir, can u make more videos Webdriverio + cucumber+ typescript combination.
@RaghavPal Жыл бұрын
Yes, sure Shreyas, I will plan
@shreyasmandlik6354 Жыл бұрын
@@RaghavPal Thank u 🙏
@tayyabanoreen7522 ай бұрын
Hi, Thank you for great tutotiral. I am getting this error: TypeError: expect(...).toHaveTextContaining is not a function Please guide how to resolve it. Thank you
@RaghavPal2 ай бұрын
Tayyaba From what I understand, toHaveTextContaining is a matcher from Jest DOM, not WebdriverIO. WebdriverIO has its own set of matchers, which you can find in the WebdriverIO documentation. To resolve this issue, you can use the toHaveText matcher provided by WebdriverIO instead. Here's an example: javascript await expect(elem).toHaveText(expect.stringContaining('some text')) Alternatively, you can also use the expect.stringContaining matcher from Jest, which is compatible with WebdriverIO: javascript await expect(elem).toHaveText(expect.stringContaining('some text')) Make sure to import the expect function from WebdriverIO and use it correctly in your tests -
@tayyabanoreen7522 ай бұрын
@@RaghavPal Thank you so much sir for your reply. Error is resolved and test passed after I used 'await expect(elem).toHaveText(expect.stringContaining('some text'))'. Thank you!
@ecemylmaz7201 Жыл бұрын
Hi Raghav, Thank you for what you explained about webdriverio. I want to use automation for a project and I want to use webdriverio for that. However, in my project, I need to use both web automation and mobile automation in a scenario. Is it possible to automate this with webdriverio? example gherkin steps: Given I am logged in to the Web application Given I log in from the mobile application When I sent a user addition request from the web application Then I should see this request in the mobile application An example scenario is as above. Yes, I know it's a bit complicated, but how can I do this on both web and mobile in the same scenario?
@RaghavPal Жыл бұрын
Ecem Yes, it is possible to automate a scenario like the one you have described using WebDriverIO. WebDriverIO supports both web and mobile automation, and it provides a number of features that make it easy to automate complex scenarios. One way to automate this scenario would be to use multiple browser instances. You could start one browser instance for the web application and another browser instance for the mobile application. Then, you could use WebDriverIO to interact with each browser instance independently. Another way to automate this scenario would be to use the WebDriverIO multiremote feature. The multiremote feature allows you to control multiple browser instances from a single test script. This can be useful for automating complex scenarios that involve multiple devices or platforms. Here is an example of how to use the WebDriverIO multiremote feature to automate the scenario you have described: ```javascript const { MultiRemoteBrowser } = require('webdriverio'); const browserA = await MultiRemoteBrowser.newSession({ capabilities: { browserName: 'chrome', }, }); const browserB = await MultiRemoteBrowser.newSession({ capabilities: { browserName: 'safari', platformName: 'ios', deviceName: 'iPhone 13', }, }); // Log in to the web application. await browserA.execute('window.location.href = "www.example.com/login";'); await browserA.execute('document.querySelector("#username").value = "my-username";'); await browserA.execute('document.querySelector("#password").value = "my-password";'); await browserA.execute('document.querySelector("#login-button").click();'); // Log in to the mobile application. await browserB.execute('window.location.href = "www.example.com/mobile/login";'); await browserB.execute('document.querySelector("#username").value = "my-username";'); await browserB.execute('document.querySelector("#password").value = "my-password";'); await browserB.execute('document.querySelector("#login-button").click();'); // Send a user addition request from the web application. await browserA.execute('window.location.href = "www.example.com/users/new";'); await browserA.execute('document.querySelector("#name").value = "John Doe";'); await browserA.execute('document.querySelector("#email").value = "john.doe@example.com";'); await browserA.execute('document.querySelector("#submit-button").click();'); // Verify that the user addition request is visible in the mobile application. await browserB.execute('window.location.href = "www.example.com/mobile/users";'); await browserB.execute('expect(document.querySelector("#user-name").textContent).toBe("John Doe");'); // Close the browser instances. await browserA.close(); await browserB.close(); ``` This is just a simple example, but it should give you a good starting point for automating complex scenarios that involve both web and mobile automation. **Note:** The multiremote feature is still under development, so there may be some limitations. For example, the multiremote feature does not support all of the same capabilities as the regular WebDriverIO browser instances.
@ecemylmaz7201 Жыл бұрын
Thank you for your answer. I will try the multiremote feature. @@RaghavPal
@selewise Жыл бұрын
Hi I am getting this error 'ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "@wdio/cucumber-framework". [0-0] Error: Cannot find module './parse'' What I should be missing here?
@RaghavPal Жыл бұрын
Hi The error message suggests that there is an issue with initializing the "@wdio/cucumber-framework" module in your test environment. Specifically, it mentions that it couldn't find the module './parse'. Here are a few possible reasons and solutions for this error: Missing or outdated dependencies: Make sure you have all the required dependencies installed and up to date. Check your package.json file and ensure that the "@wdio/cucumber-framework" dependency is listed and properly installed. You can try running npm install or yarn install to fetch and update the dependencies. Incompatible versions: Verify that the versions of "@wdio/cucumber-framework" and other related packages are compatible. Sometimes, certain packages may require specific versions to work together seamlessly. Check the compatibility matrix or the documentation of the packages you are using to ensure that they are compatible with each other. Incorrect configuration: Double-check your WebdriverIO configuration files (e.g., wdio.conf.js) to ensure that the necessary settings for the Cucumber framework are properly configured. Pay attention to the paths and file references to make sure they are correct. Clean build and reinstall: If the above steps don't resolve the issue, you can try cleaning your project build by removing the "node_modules" directory and reinstalling all the dependencies from scratch. This can help resolve any potential conflicts or corrupted files. If none of these solutions work, it would be helpful to provide more details about your project setup, including the versions of the relevant packages, your configuration files, and any additional error messages or stack traces.
@selewise Жыл бұрын
@@RaghavPal Thanks for the reply. After struggling for a day, I deleted that project and created new one, it worked fine. Could not know the exact reason for that error, but it works now after creating new project :)
@RaghavPal Жыл бұрын
It's good to hear that creating a new project resolved the issue you were facing. The error message you encountered indicates that there was a problem initializing the @wdio/cucumber-framework module, specifically with the module ./parse being missing. Although the exact reason for the error may not be clear, it's possible that there was an issue with the configuration or setup of the previous project, which was resolved when starting fresh with a new project. In general, when encountering such errors, it can be helpful to check the following: Verify dependencies: Ensure that all the required dependencies for WebdriverIO and the Cucumber framework are properly installed and specified in your package.json or package-lock.json file. Check module versions: Make sure that the versions of the dependencies you are using are compatible with each other. Incompatibilities between different module versions can sometimes cause issues. Clean project and reinstall dependencies: If you encounter similar issues in the future, you can try cleaning the project by deleting the node_modules folder and reinstalling the dependencies using npm install. This helps to ensure that all dependencies are downloaded and installed correctly. By starting a new project, you essentially recreated the project structure and reinstalled the dependencies, which may have resolved any configuration or installation issues that were present in the previous project. If you encounter the same error again in the future, you can try the troubleshooting steps mentioned above to identify and resolve the underlying cause.
@nymishanunna97426 ай бұрын
Is there any video of yours to create Webdriver cucumber BDD project in python instead of JS please?
@RaghavPal6 ай бұрын
Nymisha Not yet.. I am adding the steps here: Creating a WebDriver Cucumber BDD project in Python involves setting up the necessary tools, libraries, and project structure to automate web testing using behavior-driven development (BDD) principles. Below is a step-by-step guide to help you get started with creating a WebDriver Cucumber BDD project in Python: ### Step 1: Set up a Python Environment 1. Install Python: Download and install Python from the official [Python website](www.python.org/downloads/). 2. Use a package manager like `pip` to install necessary libraries. ### Step 2: Install Required Libraries You will need to install the following libraries: - `Selenium`: Library for automated web testing. - `Behave`: BDD framework for Python. - `WebDriver`: Python binding for Selenium WebDriver. You can install these libraries using pip: ```bash pip install selenium behave webdriver_manager ``` ### Step 3: Project Structure Create a directory structure for your project: ``` project_folder/ | |-- features/ | |-- steps/ | | |-- __init__.py | | |-- example_steps.py | | | |-- example.feature | |-- pages/ | |-- __init__.py | |-- example_page.py | |-- resources/ | |-- drivers/ | |-- .gitignore |-- behave.ini |-- requirements.txt ``` ### Step 4: Create Feature File Create a feature file (`example.feature`) in the `features` directory: ```feature Feature: Example Feature Scenario: User visits the website Given User is on the homepage When User clicks on a button Then Something happens ``` ### Step 5: Write Page Objects Create a page object file (`example_page.py`) in the `pages` directory: ```python class ExamplePage: def __init__(self, driver): self.driver = driver def click_button(self): self.driver.find_element_by_xpath("//button").click() ``` ### Step 6: Write Step Definitions Create a step definitions file (`example_steps.py`) in the `features/steps` directory: ```python from behave import given, when, then from pages.example_page import ExamplePage @given('User is on the homepage') def step_impl(context): context.page = ExamplePage(context.driver) @when('User clicks on a button') def step_impl(context): context.page.click_button() @then('Something happens') def step_impl(context): assert context.page.check_something() ``` ### Step 7: Run the Tests Run the tests using the following command from the project directory: ```bash behave ``` This will execute the feature file scenarios using the step definitions and page objects you have created. ### Step 8: Additional Configuration - Configure `behave.ini` for specifying which browser to use and other settings. - You can also use `WebDriverManager` to manage web drivers automatically. This guide provides a basic setup for creating a WebDriver Cucumber BDD project in Python. You can extend and customize this setup as per your project requirements. --
@arijitmohanty8216 Жыл бұрын
Hi sir, this video is very helpful and it will help me lot. Sir I wanted to know if I have more scenarios like after login complete data entry with multiple fileds then I need to put this in feature file and then .js file right sir. But how I doing that kindly give your valuable advice Thanks Arijit
@RaghavPal Жыл бұрын
Hi Arijit, Yes, you can define your scenarios in a feature file using Gherkin syntax and then implement them in a JavaScript file using WebdriverIO. Here's an example of how you could define a scenario for data entry with multiple fields in a feature file: Feature: Data entry with multiple fields As a user I want to enter data in multiple fields So that I can submit the form Scenario: Enter data in multiple fields Given I am on the data entry page When I enter "John" in the first name field And I enter "Doe" in the last name field And I enter "johndoe@example.com" in the email field And I enter "1234567890" in the phone number field And I click the submit button Then I should see a success message In the above example, we have defined a scenario with multiple steps. Each step corresponds to an action that the user performs on the page. The steps are defined using Gherkin syntax, which is a way to write tests in a human-readable format. Once you have defined the scenario in a feature file, you can implement it in a JavaScript file using WebdriverIO. Here's an example of how you could implement the steps for the above scenario: const { Given, When, Then } = require('cucumber'); Given('I am on the data entry page', function () { // Navigate to the data entry page browser.url('/data-entry'); }); When('I enter {string} in the first name field', function (firstName) { // Enter the first name in the first name field const firstNameField = $('input[name="first_name"]'); firstNameField.setValue(firstName); }); When('I enter {string} in the last name field', function (lastName) { // Enter the last name in the last name field const lastNameField = $('input[name="last_name"]'); lastNameField.setValue(lastName); }); When('I enter {string} in the email field', function (email) { // Enter the email in the email field const emailField = $('input[name="email"]'); emailField.setValue(email); }); When('I enter {string} in the phone number field', function (phoneNumber) { // Enter the phone number in the phone number field const phoneNumberField = $('input[name="phone_number"]'); phoneNumberField.setValue(phoneNumber); }); When('I click the submit button', function () { // Click the submit button const submitButton = $('button[type="submit"]'); submitButton.click(); }); Then('I should see a success message', function () { // Verify that the success message is displayed const successMessage = $('.success-message'); expect(successMessage).toBeDisplayed(); }); In the above example, we have implemented each step of the scenario as a separate function using WebdriverIO. The functions use WebdriverIO commands to perform actions on the page and verify that the expected elements are displayed. You can save the above JavaScript code in a file, such as data-entry-steps.js, and then link it to your feature file in your wdio.conf.js configuration file: exports.config = { // ... specs: [ './features/*.feature' ], // ... cucumberOpts: { require: [ './step-definitions/data-entry-steps.js' ] } }; This tells WebdriverIO to look for feature files in the ./features directory and to use the ./step-definitions/data-entry-steps.js file as the implementation for the steps in the feature
@shyamalaS-x1f Жыл бұрын
This is an excellent video with detailed explanation.@RaghavPal i could not navigate from feature file to stepdefination file .Installed Cucumber plugin and if do control click still it does not navigate to stepdef from feature file.Please reply sir.
@RaghavPal Жыл бұрын
Hi Shyamala There are a few things you can try if you are unable to navigate from a feature file to a step definition file in WebdriverIO using the Cucumber plugin: 1. Make sure that the Cucumber plugin is installed correctly. You can check this by opening the command prompt and running the following command: ``` npm install -g cucumber-js ``` 2. Make sure that the Cucumber plugin is enabled in your WebdriverIO project. You can do this by adding the following line to your `wdio.conf.js` file: ``` plugins: ['cucumber'], ``` 3. Make sure that the feature file and the step definition file are in the same directory. 4. Make sure that the step definition file has the same name as the feature file, but with the `.steps.js` extension. For example, if the feature file is called `login.feature`, the step definition file should be called `login.steps.js`. 5. Make sure that the step definition file contains a function for each step in the feature file. The function name should be the same as the step name, but with the first letter capitalized. For example, if the step in the feature file is `Given I am on the login page`, the step definition function should be called `GivenI Am On The Login Page`. If you have tried all of these things and you are still unable to navigate from a feature file to a step definition file, you may need to contact the developer of the Cucumber plugin for assistance. Here are some additional things to keep in mind: * The Cucumber plugin is not compatible with all versions of WebdriverIO. Make sure that you are using a compatible version of WebdriverIO. * The Cucumber plugin may not be compatible with all IDEs. If you are using an IDE that is not compatible with the Cucumber plugin, you may need to use a different IDE. * The Cucumber plugin may not be compatible with all operating systems. If you are using an operating system that is not compatible with the Cucumber plugin, you may need to use a different operating system. I hope this helps
@shyamalaS-x1f Жыл бұрын
@@RaghavPal thank you so much sir 😊.Such a detailed explanation
@sjohn5954 Жыл бұрын
Hi sir ,good morning . When can we get the interview calls on testing ?
@RaghavPal Жыл бұрын
When you will apply and have a relevant skill set as per the job requirements
@sjohn5954 Жыл бұрын
@@RaghavPal i applied as automation engineering still not getting calls sir ? Will recession continue for next 6 months .?
@RaghavPal Жыл бұрын
The job market will be tough, I suggest that you use this time to increase your skill set and keep applying meanwhile
@sjohn5954 Жыл бұрын
@@RaghavPal thank you so much sir I am thinking to learn api automation is it a good idea ?
@RaghavPal Жыл бұрын
Yes, its very good. Can check API Testing section here - automationstepbystep.com/
@saranyababu1359 Жыл бұрын
Sir, Can't we have cucumber tests and normal tests in same project ? In testng its possible right , we can run cucumber tests using TestNgTEstRunner and as well normal tests . If we use command mvn test , it runs both normal and cucumber test. Is it possible in webdriverIO ? Big Thanks for all your videos and more than that you are replying for all the queries we asking. Great work
@RaghavPal Жыл бұрын
Hi Saranya Yes, you can have cucumber tests and normal tests in the same project. In fact, it is a common practice to do so. Cucumber tests are a great way to write acceptance tests, while normal tests can be used to test specific features or functionality. In TestNG, you can run cucumber tests and normal tests using the same runner, the `TestNGTestRunner`. This runner will automatically detect and run all of the cucumber tests in your project. You can also use the `mvn test` command to run both cucumber tests and normal tests. In WebDriverIO, you can also run cucumber tests and normal tests in the same project. You can use the `Cucumber` class to run cucumber tests, and the `TestSuite` class to run normal tests. You can also use the `mvn test` command to run both cucumber tests and normal tests. Here is an example of how you would run cucumber tests and normal tests in WebDriverIO: ``` package com.example; import com.codeborne.selenide.Configuration; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions( features = "src/test/resources/features", glue = "com.example.steps" ) public class CucumberTestSuite { static { Configuration.browser = "chrome"; Configuration.startMaximized = true; } } ``` This example will run all of the cucumber tests in the `src/test/resources/features` directory. It will also run all of the normal tests in the `com.example.steps` package. You can run this example by running the following command: ``` mvn test ``` This will run both the cucumber tests and the normal tests in your project.
@saranyababu1359 Жыл бұрын
@@RaghavPal Sir is this example for selenium testng+cucmber. I am looking for webdriverIO+cucumber
@RaghavPal Жыл бұрын
Yes, can also check some online examples
@ShilpiSoni-l4v Жыл бұрын
This is an excellent video with detailed explanation.@RaghavPal . I am not able to execute command "./node_modules/.bin/cucumber-js" as its throwing the error as "Parse error in "features/login.demo.feature" (5:1): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'and clicks on login button' " How to resolve this?
@RaghavPal Жыл бұрын
Shilpi The error message "Parse error in "features/login.demo.feature" (5:1): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'and clicks on login button'" indicates that there's a syntax error in your Cucumber feature file at line 5. Here's how you can resolve it: 1. Review line 5 in your "features/login.demo.feature" file: Go back to your feature file and examine line 5 closely. Look for any typos, missing keywords, or misplaced characters. 2. Ensure proper Gherkin syntax: Make sure the line adheres to the proper Gherkin syntax for steps. It should start with a keyword like "Then," "Given," or "When," followed by the action and any optional details. In your case, "and clicks on login button" is missing a keyword at the beginning. 3. Check for leading or trailing whitespace: Sometimes, unexpected whitespace characters like tabs or spaces at the beginning or end of the line can also cause parsing errors. Ensure that the line starts and ends cleanly. 4. Refer to Cucumber documentation: If you're still unsure about the correct syntax, refer to the official Cucumber documentation for step definitions and keywords: cucumber.io/docs/gherkin/. 5. Use tools for validation: Some tools like "gherkin-lint" or "cucumber-js cucumber linter" can help you validate your feature files for syntax errors before running the tests. 6. Share the line content: If you're still struggling to identify the issue, consider sharing the exact content of line 5 from your feature file for further diagnosis. By following these steps, you should be able to identify and fix the syntax error in your Cucumber feature file and successfully execute the "./node_modules/.bin/cucumber-js" command. Remember, proper indentation and adherence to Gherkin syntax are crucial for Cucumber to understand your feature files and execute the tests correctly.
@roblesrt Жыл бұрын
Hi Sir, can you do webdriverio + cucumber + intercept service?
@RaghavPal Жыл бұрын
I will check and plan Robert
@gctpalani2020 Жыл бұрын
is there a way to debug wdio mocha in local
@RaghavPal Жыл бұрын
Yes, you can debug WebdriverIO Mocha tests locally using the Chrome DevTools or Node.js debugger. Here are the steps to debug WebdriverIO Mocha tests using the Node.js debugger: Add the debug flag to the npm test command in your package.json file: "scripts": { "test": "node --inspect-brk ./node_modules/.bin/wdio" } Start your test runner in debug mode by running npm run test in your terminal Open the Chrome browser and navigate to the URL chrome://inspect Click the "Open dedicated DevTools for Node" link at the bottom of the page In the DevTools window, click the "Sources" tab Click the "Add folder to workspace" button and select the root folder of your project Set breakpoints in your test code by clicking on the line number in the "Sources" tab Refresh the test page in your browser to trigger the breakpoint Use the debugging tools in the DevTools window to step through your code and debug the issue By following these steps, you can debug your WebdriverIO Mocha tests using the Node.js debugger in a local environment
@RoyFernandoKumalaManihuruk Жыл бұрын
Can you share for automation mobile ios?
@RaghavPal Жыл бұрын
Have not created yet on WebdriverIO, can check more here - automationstepbystep.com/
@leoamato6113 Жыл бұрын
interesting! thanks!
@RaghavPal Жыл бұрын
Most welcome
@Nikkii_Trippy_Tours10 ай бұрын
Not able to compile ts
@RaghavPal9 ай бұрын
Nikita will need more details and logs
@rameshganamana7944 Жыл бұрын
sir please do some videos on webdriver IO with cucumber
@RaghavPal Жыл бұрын
I will do more on this
@kalyanpatil203 Жыл бұрын
All I can say is I felt I am in a class , not a virtual class🙏
@RaghavPal Жыл бұрын
Great to hear this Kalyan. Humbled
@Nikkii_Trippy_Tours10 ай бұрын
Given is not defined
@RaghavPal9 ай бұрын
will need more details and logs for the error Nikita
@tiendat1967 Жыл бұрын
Nice turtorial , but for me it only shows 0 scenarios 0 steps
@RaghavPal Жыл бұрын
will need to check the details and setup Tien. will need to check the logs too
@ninu24antony Жыл бұрын
hi, i created everything , but the last thing to show the message is not passing.. it showing some error, I wrote the code like this Then(/^user naviagtes to this message$/, async() => { await expect($('#flash')).toHaveTextContaining('You logged into a secure area!'); }); error Error: Expect $(`#flash`) to have text containing Error: Expect $(`#flash`) to have text containing Expected: "You logged into a secure area!" Received: undefined
@RaghavPal Жыл бұрын
The error message is telling you that the element with the ID `#flash` does not contain the text `You logged into a secure area!`. This could be because the element does not exist, because it is not visible, or because it contains different text. Here are a few things you can do to troubleshoot the error: * Make sure that the element with the ID `#flash` exists on the page. You can do this by using the `browser.isExisting()` method. * Make sure that the element with the ID `#flash` is visible. You can do this by using the `browser.isVisible()` method. * Make sure that the element with the ID `#flash` contains the text `You logged into a secure area!`. You can do this by using the `browser.getText()` method. If you have verified that all of the above are true, then the error is likely due to a timing issue. This means that WebdriverIO is trying to interact with the element before it is fully loaded. To fix this, you can add a wait to your test step. You can do this using the `browser.waitUntil()` method. Here is an example of how to use the `browser.waitUntil()` method to fix the timing issue: ``` Then(/^user naviagtes to this message$/, async() => { await browser.waitUntil(() => { return browser.getText('#flash') === 'You logged into a secure area!'; }, 5000); await expect($('#flash')).toHaveTextContaining('You logged into a secure area!'); }); ``` This code will wait for up to 5 seconds for the element with the ID `#flash` to contain the text `You logged into a secure area!`. If the element does not contain the text within 5 seconds, the test will fail