title: Getting this error in Cannot read properties of undefined (reading 'setValue') in WebDriverIO cucumber Framework
body: <p>I am new to webdriverio and try to run the basic tests in cucumber framework, When I am running  the test browser is loading and opening the website but its failing in the second step (Input username and password )<br />
  I have tried looking for a solution but didnt get anything. Could you please help me to solve this</p>
  <p>GitHub: <a href="https://github.com/Jyoti2190-Test/webdrieriopractice/tree/master" rel="nofollow noreferrer">https://github.com/Jyoti2190-Test/webdrieriopractice/tree/master</a></p>
  <p>Note: Have already tried adding browser.pause(3000).</p>
  <p>Please find the code below<br />
  <strong>Feature File</strong></p>
  <pre><code>Feature: To test the login functionality in &quot;The Internet Herokuapp&quot;
  
      Background:
          Given the user is on login page
      Scenario: The one where user logs in using valid credentials
  
          When the user enters username as &quot;tomsmith&quot; and password as &quot;SuperSecretPassword!&quot;
          And clicks on login button
          Then the user must navigate to secure area page displaying a message &quot;You logged into a secure area!&quot;
  
      Scenario Outline: The one where user logs in using invalid credentials
          When the user enters username as &quot;&lt;username&gt;&quot; and password as &quot;&lt;password&gt;&quot;
          And clicks on login button
          Then the user must remain on login page displaying a message &quot;&lt;errorMessage&gt;&quot;
          Examples:
              | username | password | errorMessage |
              | james | SuperSecretPassword! | Invalid username! |
              | tomsmith | SuperPassword! | Invalid password! |  
  </code></pre>
  <p><strong>PageObject File (login.page.js)</strong></p>
  <pre><code>class LoginPage {
      get userNameTextBox() { return browser.element('#username'); }
      get passwordTextBox() { return browser.element('#password'); }
      get loginButton() { return browser.element('button[type=&quot;submit&quot;]'); }
  
      get loginPageElement() { return browser.element('div[class=&quot;example&quot;] h2'); }
      get messageElement() { return browser.element('#flash'); }
  
  }
  
  export default new LoginPage();  
  
  </code></pre>
  <p><strong>Step.js</strong></p>
  <pre><code>import { Given, When, Then } from '@cucumber/cucumber';
  const LoginPage = require('../pages/login.page');
  const SecurePage = require('../pages/secure.page');
  
  Given('the user is on login page', function () {
      browser.url(&quot;https://the-internet.herokuapp.com/login&quot;);
      expect(browser).toHaveTitle('The Internet');
  });
  
  When('the user enters username as {string} and password as {string}', function (username, password)     
  {
      browser.pause(6000);
      LoginPage.userNameTextBox.setValue(username);
      LoginPage.passwordTextBox.setValue(password);
  });
  
  When('clicks on login button', function () {
      LoginPage.loginButton.click();
  });
  
  Then('the user must navigate to secure area page displaying a message {string}', function (successMessage) {
      expect(SecurePage.secureAreaElement).toExist();
      expect(SecurePage.secureAreaElement).toHaveTextContaining('Secure Area');
  
      expect(SecurePage.messageElement).toExist();
      expect(SecurePage.messageElement).toHaveTextContaining(successMessage);
  });
  
  Then('the user must remain on login page displaying a message {string}', function (string) {
      expect(LoginPage.loginPageElement).toExist();
      expect(LoginPage.loginPageElement).toHaveTextContaining('Login Page');
      expect(LoginPage.messageElement).toExist();
      expect(LoginPage.messageElement).toHaveTextContaining(errorMessage);
  });  
  
  </code></pre>
  <pre><code>**Error Log**  
  
  [0-0] Error in &quot;0: When the user enters username as &quot;tomsmith&quot; and password as &quot;SuperSecretPassword!&quot;&quot;
  TypeError: Cannot read properties of undefined (reading 'setValue')
      at World.&lt;anonymous&gt; (..\Documents\WebDriverIO_Cucumber_Project\features\step-definitions\/step.js:13:31)
      at World.executeAsync (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@wdio\utils\build\shim.js:325:27)
      at World.testFrameworkFnWrapper (..\WebDriverIO_Cucumber_Project\node_modules\@wdio\utils\build\test-framework\testFnWrapper.js:45:32)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at Object.wrapPromiseWithTimeout (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\time.ts:56:10)
      at Object.run (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\user_code_runner.ts:86:16)
      at Object.run (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\runtime\step_runner.ts:50:20)
      at TestCaseRunner.invokeStep (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\runtime\test_case_runner.ts:130:12)
      at TestCaseRunner.runStep (..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\runtime\test_case_runner.ts:307:20)
      at ..\Documents\WebDriverIO_Cucumber_Project\node_modules\@cucumber\cucumber\src\runtime\test_case_runner.ts:210:36
  </code></pre>
  <pre><code>&quot;keywords&quot;: [],
    &quot;author&quot;: &quot;Jyoti Singhal&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@babel/cli&quot;: &quot;^7.6.4&quot;,
      &quot;@babel/core&quot;: &quot;^7.6.4&quot;,
      &quot;@babel/preset-env&quot;: &quot;^7.6.3&quot;,
      &quot;@babel/register&quot;: &quot;^7.6.2&quot;,
      &quot;@wdio/allure-reporter&quot;: &quot;^7.16.11&quot;,
      &quot;@wdio/cli&quot;: &quot;^7.16.12&quot;,
      &quot;@wdio/cucumber-framework&quot;: &quot;^7.16.12&quot;,
      &quot;@wdio/local-runner&quot;: &quot;^7.16.12&quot;,
      &quot;@wdio/selenium-standalone-service&quot;: &quot;^7.16.11&quot;,
      &quot;@wdio/spec-reporter&quot;: &quot;^7.16.11&quot;,
      &quot;chromedriver&quot;: &quot;^97.0.0&quot;
  </code></pre>