I am trying to run parallel tests in 2 browsers using, Testng and cucumber.
Getting the below exception ,
cucumber.runtime.CucumberException: When a hook declares an argument it must be of type cucumber.api.Scenario. public void com.sample.data_republic.sample_ebay.EbayTest.loadBrowser(java.lang.String) at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:52) at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:224)
Code sample given below.
import cucumber.api.java.After;
import cucumber.api.java.Before;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Parameters;
public class EbayTest extends EbayPageObjects {
public WebDriver driver;
Properties propertyObj;
@Before
@Parameters("browser")
public void loadBrowser(String browser) {
// If the browser is Firefox, then do this
if (browser.equalsIgnoreCase("firefox")) {
System.setProperty("webdriver.gecko.driver", "src/test/resources/drivers/geckodriver");
driver = new FirefoxDriver();
} else if (browser.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver");
driver = new ChromeDriver();
}
propertyObj = readPropertyFile();
driver.get(propertyObj.getProperty("url"));
}