I googled and found most of scripts were written in Jbehave with junit. But I'm trying to integrate Jbehave with testNG framework. And the following were I tried so far.
Feature file:
Scenario: Check the google search engine
Given : Open the google home page www.google.com
When : Enter test automation in search box
Then : Proper result should be displayed in results page
Test step class file:
public class GoogleSearchEngine_Steps {
public static WebDriver driver;
@Given("Open the google home page $url")
public static void openUrl(String url) throws Exception {
try {
driver = new FirefoxDriver();
driver.get(url);
} catch (Exception ex) {
ex.printStackTrace();
}
}
@When("Enter $searchKeyword in search box")
public static void searchKeyword(String searchKeyword) throws Exception {
try {
driver.findElement(By.xpath(".//*[@id='gs_htif0']")).sendKeys(searchKeyword);
driver.findElement(By.xpath(".//*[@id='tsf']/input[1]")).click();
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Then("Proper result should be displayed in results page")
public static void result() throws Exception {
try {
driver.quit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
But I have stuck to create a test runner class file using TestNg. I'm not sure How to start.
Can somebody help me to create a test runner class file which will execute the above code.