Hi All,
I am trying to execute my webdriver tests using Jbehave BDD.
I have an parameterized story file which contains Examples like below :
Examples:
|username |lastname |email |phone
|company |errormsg |
|Test |Test |[email protected] |
9966004535 |SDET |Please enter requirement |
|Test2 |Test2 |[email protected] |
9966004535 |SDET |Please enter requirements |
In second set data it will fail because of assertion error and it has to
take the screenshot. *Sometimes it is working but sometimes its failing*
below is the error:
INFO [pool-1-thread-1] (MyStoryReporter.java:129) - Then I should see error
message '$errormsg' >> Failed org.jbehave.core.failures.UUIDExceptionWrapper
: Then I should see error message '$errormsg'
Screenshot of page '[unknown page title]. Will try again. Cause: WebDriver
has not been found for this thread.
Please verify you are using the correct WebDriverProvider, with the
appropriate credentials if using remote access, e.g. to SauceLabs:
-DSAUCE_USERNAME=xxxxxx -DSAUCE_ACCESS_KEY=xxx-xxxx-xxxx-xxxx-xxx
Screenshot of page '[unknown page title]' has **NOT** been saved to 'D:\SDET
\jbehave-test\target\jbehave/screenshots/failed-scenario-383f714e-f944-4dda-
afa8-3eaa5a8ba859.png' because error 'WebDriver has not been found for this
thread.
Please verify you are using the correct WebDriverProvider, with the
appropriate credentials if using remote access, e.g. to SauceLabs: -
DSAUCE_USERNAME=xxxxxx -DSAUCE_ACCESS_KEY=xxx-xxxx-xxxx-xxxx-xxx '
encountered. Stack trace follows:
org.jbehave.web.selenium.DelegatingWebDriverProvider$DelegateWebDriverNotFound:
WebDriver has not been found for this thread.
Please verify you are using the correct WebDriverProvider, with the
appropriate credentials if using remote access, e.g. to SauceLabs:
-DSAUCE_USERNAME=xxxxxx -DSAUCE_ACCESS_KEY=xxx-xxxx-xxxx-xxxx-xxx
at
org.jbehave.web.selenium.DelegatingWebDriverProvider.get(DelegatingWebDriverProvider.java:24)
at
org.jbehave.web.selenium.DelegatingWebDriverProvider.saveScreenshotTo(DelegatingWebDriverProvider.java:35)
at
com.qe.test.jbehave.providers.LocalWebDriverProvider.saveScreenshotTo(LocalWebDriverProvider.java:26)
at
org.jbehave.web.selenium.WebDriverScreenshotOnFailure.afterScenarioFailure(WebDriverScreenshotOnFailure.java:56)
at
org.jbehave.web.selenium.WebDriverScreenshotOnFailure.afterScenarioWithExamplesFailure(WebDriverScreenshotOnFailure.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.jbehave.core.steps.StepCreator$MethodInvoker.invoke(StepCreator.java:805)
at
org.jbehave.core.steps.StepCreator$BeforeOrAfterStep.perform(StepCreator.java:491)
at
org.jbehave.core.steps.StepCreator$UponFailureStep.doNotPerform(StepCreator.java:560)
at
org.jbehave.core.embedder.PerformableTree$SomethingHappened.run(PerformableTree.java:372)
at
org.jbehave.core.embedder.PerformableTree$PerformableSteps.perform(PerformableTree.java:1072)
at
org.jbehave.core.embedder.PerformableTree$ExamplePerformableScenario.perform(PerformableTree.java:1012)
at
org.jbehave.core.embedder.PerformableTree$PerformableScenario.perform(PerformableTree.java:883)
at
org.jbehave.core.embedder.PerformableTree$PerformableStory.performScenarios(PerformableTree.java:811)
at
org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:784)
at
org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:416)
at
org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:387)
at
org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:291)
at
org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:265)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
I have PerstoryWebDriverSteps class where i am handling driver
intialization and quit. Please refer below
public class PerStoryWebDriverSteps extends WebDriverSteps {
private static final Logger LOGGER = Logger
.getLogger(PerStoryWebDriverSteps.class);
private boolean initialized;
public PerStoryWebDriverSteps(WebDriverProvider driverProvider) {
super(driverProvider);
}
@BeforeStory
public void beforeStory() {
//Before story
}
@AfterStory
public void afterStory() {
// After story
}
@BeforeScenario(uponType = ScenarioType.NORMAL)
public void beforeNormal() throws Exception {
LOGGER.info(" ****** Initializing Driver Provider *********** ");
getDriverProvider().initialize();
LOGGER.info("Driver Provider initialized Successfully");
getDriverProvider().get().manage().window().maximize();
LOGGER.info(" ******* Maximizing Browser's Window ********** ");
initialized = true;
}
@BeforeScenario(uponType = ScenarioType.EXAMPLE)
public void beforeExample() throws Exception {
if (!initialized) {
getDriverProvider().initialize();
initialized = true;
}
}
@AfterScenario(uponType = ScenarioType.EXAMPLE)
public void afterExample() throws Exception {
getDriverProvider().end();
initialized = false;
}
@AfterScenario(uponType = ScenarioType.NORMAL)
public void afterNormal() throws Exception {
if (initialized) {
LOGGER.info(" ****** Ending Driver Provider *******");
getDriverProvider().end();
LOGGER.info(" ********* DriverProvider ended successfully********* ");
initialized = false;
}
}
I don't know what is the exact problem, please help me to resolve this
issue.
--
You received this message because you are subscribed to the Google Groups
"JBehave User" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/jbehave-user/2bde024e-f933-4a31-8e48-6f3f2f935ac2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.