I am new to Selenium and practicing Cucumber. I am doing a sample project in which I created a "CreateLead" test. The test executes successfully using Junit when I do not use "Background:" in the feature file.
If I include the "Background:" in the feature file, I face "unrooted test" exception. Can someone please help me to resolve this?
CreateLead Feature File
Feature: Creating Lead
In order to get more revenue
As a sales person
I want to create leads
Background:
Given I am logged in salesforce in Mozilla
Given I am logged in salesforce in Chrome
@CreateLead
Scenario Outline: Creating Leads
Given Browser is "<Browser>"
And I click on the tab "LeadTab"
And I click on the button "NewLeadButton"
Examples:
|Browser |
|Mozilla |
|Chrome |
CreateLeadTest
package com.qtpselenium.CreateLeadTestCase;
import org.junit.Assert;
import com.qtpselenium.util.Webconnector;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
public class CreateLeadTest {
Webconnector Selenium= Webconnector.getInstance();
@Given("^I am logged in salesforce in \"([^\"]*)\"$")
public void I_am_logged_in_salesforce(String browser) throws Throwable{
Selenium.openBrowser(browser);
Assert.assertTrue("Not logged in", Selenium.isLoggedIn());
}
@Given("^Browser is \"([^\"]*)\"$")
public void Browser_is(String browser) throws Throwable{
Selenium.openBrowser(browser);
Selenium.isLoggedIn();
}
@And("^I click on the tab \"([^\"]*)\"$")
public void I_click_on_the_tab(String object)throws Throwable{
Selenium.click(object);
}
@And("^I click on the button \"([^\"]*)\"$")
public void I_click_on_the_button(String object)throws Throwable{
Selenium.click(object);
}
Error: Unrooted tests- @Ignore:Given I am logged in Salesforce in Mozilla @Ignore:Given I am logged in Salesforce in Chrome
Background start to run before the Scenario and end with Hooks.
Try to delete the "Given I am logged in salesforce in Chrome" from the background and execute the test. Which means that we aim to run the test in Mozilla for this instance.
I am sure the test executes succesfully