Skip to content
Advertisement

Java (Silenium) – import statement done however method is not visible

I am relatively new to Java and Selenium.

I have a project (Selenium) created by other developer.

  1. I created my Java class:
    public class ST_VladsSteps extends Inter
    {
    ...
    }
  1. The class which method SupplierPortalLogin() I want to use is called
    package com.abc.application.def.tests;
    public class LoginTest {...}
  1. In my class on the top I have put a statement:

import com.resmed.application.GoScripts.tests.LoginTest;

  1. In my method,
     @When("^User keys in "([^"]*)" and "([^"]*)"$")
    
     public void userProvidesUserNameAndPassword(String UserName) throws InterruptedException {
    
     SupplierPortalLogin(UserName,TempString);  
    }

When I use the method SupplierPortalLogin(UserName,TempString) I have an error message,

The method SupplierPortalLogin(String, String) is undefined for the type ST_VladsSteps.

  1. I can see in the project that other Java classes use the same import com.resmed.application.GoScripts.tests.LoginTest; statement and use this method within their methods.

Please, help me to understand what I am doing wrong.

Answer

In my method @When("^User keys in "([^"])" and "([^"])"$")

Your cucumber step required two arguments but you are passing single argument to the method userProvidesUserNameAndPassword

Current code:

    public void userProvidesUserNameAndPassword(String UserName) throws InterruptedException {
    SupplierPortalLogin(UserName,TempString); 
  }

Updated code:

  public void userProvidesUserNameAndPassword(String UserName, String TempString) throws InterruptedException {
    SupplierPortalLogin(UserName,TempString); 
  }
Advertisement