title: Open Browser & Navigate - Java Automated Testing Selenium
body: <pre><code> Feature: Login to Website
  
    #Login in Chrome
    Scenario: Login using Chrome
    Given I open Chrome
    When I browse to Website
    Then I login to Website using &quot;user1&quot; and &quot;password1&quot;
  </code></pre>
  <p>Global Base Class</p>
  <pre><code>public class base {
  
  public WebDriver driver;
  public Properties prop;
  public ChromeOptions coptions;
  
  public WebDriver initializeDriver() throws IOException
  {
  
      String browserName= &quot;chrome&quot;;
      System.out.println(browserName);
      String pathToDriver = &quot;&quot;;
  
      if(browserName.equals(&quot;chrome&quot;))
      {
          pathToDriver = &quot;C:\\Repositories\\automationProject\\webDrivers\\chromedriver.exe&quot;;
          System.setProperty(&quot;webdriver.chrome.driver&quot;, pathToDriver);
          coptions.addArguments(&quot;disable-infobars&quot;);
          coptions.addArguments(&quot;--start-maximized&quot;);
          driver= new ChromeDriver(coptions);
          //execute in chrome driver
  
      }
  
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      return driver;
  }
  </code></pre>
  <p>Login</p>
  <pre><code>public class login extends base {
  
  @Given(&quot;^I open Chrome$&quot;)
  public void iOpenChrome() throws Throwable {
      driver = initializeDriver();
  }
  
  @When(&quot;^I browse to Website$&quot;)
  public void iBrowseToWebsite() {
      driver.get(&quot;https://www.website.com/&quot;);
  }
  
  @Then(&quot;^I login to Website using \&quot;([^\&quot;]*)\&quot; and \&quot;([^\&quot;]*)\&quot;£\&quot;$&quot;)
  public void iLoginToWebsiteUsingAnd£(String username, String password) throws Throwable {
      driver.findElement(By.id(&quot;UserName&quot;)).sendKeys(username);
      driver.findElement(By.id(&quot;Password&quot;)).sendKeys(password);
      driver.findElement(By.id(&quot;btnLogin&quot;)).click();
  }
  </code></pre>
  <p>}</p>
  <p>The issue is that when running this feature I am getting the below error which I cannot understand why this is happening as it gives me no help in where the error is.</p>
  <p>Undefined step: Given I open Chrome</p>
  <p>Undefined step: When I browse to Website</p>
  <p>Undefined step: Then I login to Website using &quot;user1&quot; and &quot;password1&quot;</p>