-
Notifications
You must be signed in to change notification settings - Fork 40
ScenarioContext
In some cases you may want to share some state between scenario steps but only in a particular scenario context. This is when ScenarioContext
comes with help. ScenarioContext
is a communication channel between scenario steps. It was implemented as a HashMap
where one step is storing information for other steps. Let's consider that we have scenario steps implementation in two different classes. If we want to share some information between two classes we can just inject ScenarioContext
in both classes:
@ScenarioScoped
public class AuthorPageSteps {
@Inject
private ScenarioContext scenarioContext;
//...
@When("^I build a \"([^\"]*)\" configuration with ComponentConfigBuilder$")
public void iBuildAConfigurationWithComponentConfigBuilder(String configName) {
List<ConfigurationEntry> config = new ComponentConfigBuilder()
.setTab("Tab1")
.add("text field", "Text Field", "textfield")
.add("path field", "Path Field", "Node1/Node2/Node3")
.build();
scenarioContext.add(configName, config);
}
//...
}
@ScenarioScoped
public class AuthorPageStepsSidekick {
@Inject
private ScenarioContext scenarioContext;
//...
@When("^I use the \"([^\"]*)\" configuration from JSON$")
public void iUseTheConfigurationFromJSON(String configName) {
ComponentConfig config = new JsonToComponentConfig().readConfig(configName);
scenarioContext.add(configName, config.getConfig());
}
//...
}
As you can see ScenarioContext
class has built-in helpers for getting String's and List's and other types. If you want to learn more about ComponentConfigBuilder
and different ways if storing component configurations please refer to Storing component configurations tutorial.
- Configuring Bobcat
- Selenium enhancements
- Cucumber enhancements
- Traffic analyzer
- Email support
- Reporting
- Cloud integration
- Mobile integration
- Executing tests on different environments
- Working with multiple threads
- Tips and tricks
- Authoring tutorial - Classic
- AEM Classic Authoring Advanced usage
- Siteadmin
- Sidekick
- Aem Component
- Working with author pages
- Working with Publish pages
- Advanced component interactions
- Working with Context Menu
- Using Aem Content Tree
- Aem Content Finder
- Storing component configurations
- Working with packages
- Jcr Support
- Authoring tutorial - Touch UI
- Adding and editing a component
- Sites management tutorial