本文整理汇总了Java中cucumber.api.java.After类的典型用法代码示例。如果您正苦于以下问题:Java After类的具体用法?Java After怎么用?Java After使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
After类属于cucumber.api.java包,在下文中一共展示了After类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: embedScreenshot
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void embedScreenshot(Scenario scenario) {
try {
if (!scenario.isFailed()) {
// Take a screenshot only in the failure case
return;
}
String webDriverType = System.getProperty("WebDriverType");
if (!webDriverType.equals("HtmlUnit")) {
// HtmlUnit does not support screenshots
byte[] screenshot = getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
scenario.write(somePlatformsDontSupportScreenshots.getMessage());
}
}
示例2: teardown
import cucumber.api.java.After; //导入依赖的package包/类
/**
* Runs after every Cucumber test scenario.
* @param scenario The test scenario that has run
*/
@After
public void teardown(Scenario scenario) {
logger.debug("After cucumber scenario: ********** {} **********", scenario.getName());
// add to the test report
outputDataUse(scenario);
outputFinalScreenshot(scenario);
outputFinalHtml(scenario);
// log the current user out, if they are logged in
if (driverWrapper.hasLink("Sign out")) {
logger.debug("Logging the current user out...");
driverWrapper.clickLink("Sign out");
}
// test cleanup (note: this will clear permanent cookies but not HTTP/Session cookies)
driverWrapper.reset();
}
示例3: afterTest
import cucumber.api.java.After; //导入依赖的package包/类
/**
* <p>
* Takes screen-shot if the scenario fails
* </p>
*
* @param scenario will be the individual scenario's within the Feature files
* @throws InterruptedException Exception thrown if there is an interuption within the JVM
*/
@After()
public void afterTest(Scenario scenario) throws InterruptedException {
LOG.info("Taking screenshot IF Test Failed");
System.out.println("Taking screenshot IF Test Failed (sysOut)");
if (scenario.isFailed()) {
try {
System.out.println("Scenario FAILED... screen shot taken");
scenario.write(getDriver().getCurrentUrl());
byte[] screenShot = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenShot, "image/png");
} catch (WebDriverException e) {
LOG.error(e.getMessage());
}
}
}
示例4: tearDown
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void tearDown(Scenario scenario) {
if (scenario.isFailed()) {
try {
logger.info("Test failed, taking screenshot");
byte[] screenshot = ((TakesScreenshot) new Augmenter().augment(getAppiumDriver()))
.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
catch (WebDriverException wde) {
System.err.println(wde.getMessage());
}
catch (ClassCastException cce) {
cce.printStackTrace();
}
}
application.tearDown();
}
示例5: afterScenario
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario( Scenario scenario ) throws Exception
{
try
{
attachLog();
if( scenario.isFailed() )
{
try
{
scenario.write( "Current Page URL is " + getDriver().getCurrentUrl() );
byte[] screenshot;
try
{
screenshot = ( ( TakesScreenshot ) getDriver() ).getScreenshotAs( OutputType.BYTES );
} catch( ClassCastException weNeedToAugmentOurDriverObject )
{
screenshot = ( ( TakesScreenshot ) new Augmenter().augment( getDriver() ) ).getScreenshotAs( OutputType.BYTES );
}
String relativeScrnShotPath = takeScreenshot().substring(takeScreenshot().indexOf("screenshots"));
Reporter.addScreenCaptureFromPath(relativeScrnShotPath, getDriver().getCurrentUrl());
} catch( WebDriverException somePlatformsDontSupportScreenshots )
{
System.err.println( somePlatformsDontSupportScreenshots.getMessage() );
}
}
} finally
{
closeDriverObjects();
}
}
示例6: discardEditedDocument
import cucumber.api.java.After; //导入依赖的package包/类
/**
* <p>
* Closes the current publication discarding current changes.
* </p><p>
* Only applicable to scenarios that leave the document in editable state; implemented as an {@linkplain After}
* hook rather than a step because this is really a test cleanup/tear-down activity that doesn't warrant expressing
* explicitly as a scenario step.
* </p><p>
* To ensure that this method gets called at the end of your scenario, tag the scenario with
* {@code @DiscardAfter}.
* </p>
*/
@After(value = "@DiscardAfter", order = 500)
public void discardEditedDocument() throws Throwable {
Publication currentPublication = testDataRepo.getCurrentPublication();
if (currentPublication != null) {
final String currentPublicationName = currentPublication.getName();
log.debug("Discarding and closing current publication: {}.", currentPublicationName);
contentPage.discardUnsavedChanges(currentPublicationName);
}
Dataset dataset = testDataRepo.getDataset();
if (dataset != null) {
String datasetName = dataset.getName();
log.debug("Discarding and closing current dataset: {}.", datasetName);
contentPage.discardUnsavedChanges(datasetName);
}
PublicationSeries series = testDataRepo.getPublicationSeries();
if (series != null) {
final String currentSeriesName = series.getName();
log.debug("Discarding and closing current series: {}.", currentSeriesName);
contentPage.discardUnsavedChanges(currentSeriesName);
}
}
示例7: afterScenario
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario() throws Exception {
// Remove any bookings made by the scenario - so next scenario can start
// with a 'clean slate'.
assertTrue("Expect bookings page to be loaded before calling this method",
courtAndTimeSlotChooserPage.isLoaded());
BookingSet bookingsThatFailedToCancel = new BookingSet();
bookingsPotentiallyMadeDuringScenario.stream().forEach(
b -> {
try {
courtAndTimeSlotChooserPage.cancelCourt(b.getCourt(), b.getTime(), b.getDate(),
b.getName(), "pAssw0rd", true);
} catch (Exception e) {
e.printStackTrace();
// Note error but continue - we'll fail later
bookingsThatFailedToCancel.add(b);
}
});
if (!bookingsThatFailedToCancel.isEmpty()) {
fail("Error cancelling bookings in scenario teardown");
}
}
示例8: after
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void after() {
takeScreenshotOnFail();
if (mActivity != null) { // Close activity after each test scenario
if (!mActivity.isFinishing()) {
mActivity.finish();
}
try {
if (mDoneSignal != null) {
if (!mDoneSignal.await(10, TimeUnit.SECONDS)) {
if (Log.D) Log.d(TAG, "FirstRunWizard activity didn't finish properly in the given time");
}
}
} catch (final InterruptedException ex) {
if (Log.D) Log.d(TAG, "FirstRunWizard activity didn't finish properly in the given time");
}
}
mDoneSignal = null;
}
示例9: afterScenario
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterScenario() {
// free allocated resources
// In case environment is not deleted we force its deletion
if (environmentDetailsPage != null) {
if (!environmentDetailsPage.isDeleted()) {
logger.debug("Deleting environment");
environmentDetailsPage.delete();
thenTheEnvironmentShouldBeDeletedWithin(10); // minutes
} else {
logger.debug("environment is already deleted: no need to force its deletion");
}
} else {
logger.debug("environmentPage is null: unable to delete environment");
}
environmentDetailsPage = null;
}
示例10: afterClass
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void afterClass(Scenario scenario) throws InterruptedException, IOException {
if (scenario.isFailed()) {
try {
byte[] screenshot =
((TakesScreenshot) AppiumDriverManager.getDriver())
.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} catch (WebDriverException wde) {
System.err.println(wde.getMessage());
} catch (ClassCastException cce) {
cce.printStackTrace();
}
System.out.println("Inside After" + Thread.currentThread().getId());
}
AppiumDriverManager.getDriver().quit();
}
示例11: takeScreenshot
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void takeScreenshot(final Scenario scenario) {
if (scenario.isFailed() && webDriver instanceof TakesScreenshot) {
final String scenarioName = scenario.getName();
takeScreenshot(scenarioName, (TakesScreenshot) webDriver);
}
}
示例12: afterScenario
import cucumber.api.java.After; //导入依赖的package包/类
/**
* Capture a selenium screenshot when a test fails and add it to the Cucumber generated report
* if the scenario has accessed selenium in its lifetime
* @throws InterruptedException
*/
@After
public void afterScenario(Scenario scenario) throws InterruptedException {
log.debug("Scenarion finished");
ScenarioGlobals scenarioGlobals = getCucumberManager().getCurrentScenarioGlobals();
TestEnvironment testNev = getSeleniumManager().getAssociatedTestEnvironment();
if (testNev != null && scenarioGlobals != null) {
boolean scenarioUsedSelenium = testNev.isWebDriverAccessedSince(scenarioGlobals.getScenarioStart());
if (scenarioUsedSelenium) {
if (scenario.isFailed()) {
log.debug("Scenarion failed while using selenium, so capture screenshot");
TakesScreenshot seleniumDriver = (TakesScreenshot) SenBotContext.getSeleniumDriver();
byte[] screenshotAs = seleniumDriver.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshotAs, "image/png");
}
}
}
getCucumberManager().stopNewScenario();
}
示例13: cleanup
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void cleanup() throws SQLException {
if (pugTSDB != null) {
try (Statement statement = pugTSDB.getDataSource().getConnection().createStatement()) {
statement.execute(" DROP ALL OBJECTS DELETE FILES ");
} finally {
pugTSDB.close();
}
}
}
示例14: cleanup
import cucumber.api.java.After; //导入依赖的package包/类
@After
public void cleanup() throws SQLException {
if (actualPug != null) {
try (Statement statement = actualPug.getDataSource().getConnection().createStatement()) {
statement.execute(" DROP ALL OBJECTS DELETE FILES ");
} finally {
actualPug.close();
}
}
}
示例15: after
import cucumber.api.java.After; //导入依赖的package包/类
/**
* Test method executed after each test method.
*/
@After
public void after() throws Exception {
// Cleanup the testing bucket
this.cleanupTestingBucket();
}