Я написал простой код в java, который откроет браузер chrome и проверит его название. Здесь я использовал концепцию Jbehave (BDD) для ее достижения.
Проблема, с которой я сталкиваюсь, заключается в том, что я не могу запустить свой конфигурационный файл.
Это мой .story file
narrative:
In order to communicate effectively to the business some functionality
As a development team
I want to use Behaviour-Driven Development
Scenario: A Scenario to open google.com
Given I open a browser
When I enter the https://www.google.com
Then google is displayed
Это мой java код для сюжетной линии
import java.util.concurrent.TimeUnit;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class DebugPluginSteps {
WebDriver driver = new ChromeDriver();
@Given("I open a browser")
public void openTheBrowser() {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@When("I enter $url")
public void typeTheUrl(String url) {
driver.get(url);
}
@Then("$title is displayed")
public void debugStepForThenTest(String title) {
if (driver.getTitle() == title) {
System.out.println("Title matched");
} else {
System.out.println("Title is not matching");
}
}
}
}
И это мой конфигурационный файл.
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.junit.JUnitStory;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
public class MyLinkedListStory extends JUnitStory {
@Override
public Configuration configuration() {
return new MostUsefulConfiguration();
}
@Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new DebugPluginSteps());
}
}
Вывод на консоль:
Starting ChromeDriver 2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a) on port 29264
Only local connections are allowed.
[1578918833.831][WARNING]: Timed out connecting to Chrome, retrying...
Jan 13, 2020 6:03:55 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]
Generating reports view to 'C:\Users\Desktop\Selenium 201\SimpleJbehave\target\jbehave' using formats '[]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
Reports view generated with 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)