當前位置: 首頁>>代碼示例>>Java>>正文


Java Scenario.write方法代碼示例

本文整理匯總了Java中cucumber.api.Scenario.write方法的典型用法代碼示例。如果您正苦於以下問題:Java Scenario.write方法的具體用法?Java Scenario.write怎麽用?Java Scenario.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cucumber.api.Scenario的用法示例。


在下文中一共展示了Scenario.write方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: embedScreenshot

import cucumber.api.Scenario; //導入方法依賴的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());
  }
}
 
開發者ID:robinsteel,項目名稱:Sqawsh,代碼行數:19,代碼來源:SharedDriver.java

示例2: afterTest

import cucumber.api.Scenario; //導入方法依賴的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());
        }
    }
}
 
開發者ID:usman-h,項目名稱:Habanero,代碼行數:24,代碼來源:ScreenShotHook.java

示例3: tearDownDriver

import cucumber.api.Scenario; //導入方法依賴的package包/類
public void tearDownDriver(Scenario scenario) throws Exception {
	
	try {
		if (ObjectRepo.driver != null) {
			
			if(scenario.isFailed())
				scenario.write(new GenericHelper(ObjectRepo.driver).takeScreenShot(scenario.getName()));
			
			ObjectRepo.driver.quit();
			ObjectRepo.reader = null;
			ObjectRepo.driver = null;
			oLog.info("Shutting Down the driver");
		}
	} catch (Exception e) {
		oLog.error(e);
		throw e;
	}
}
 
開發者ID:rahulrathore44,項目名稱:SeleniumCucumber,代碼行數:19,代碼來源:InitializeWebDrive.java

示例4: afterScenario

import cucumber.api.Scenario; //導入方法依賴的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();
    }
}
 
開發者ID:hemano,項目名稱:cucumber-framework-java,代碼行數:33,代碼來源:StartingSteps.java

示例5: outputDataUse

import cucumber.api.Scenario; //導入方法依賴的package包/類
/**
 * Output the values of any dataset entries used in this test scenario, useful for investigating test failures and
 * as a record of what exactly was tested. The output gets picked up by the Cucumber reports and plugins.
 * @param scenario  The scenario just completed
 */
private void outputDataUse(Scenario scenario) {
    List<String> keys = driverWrapper.getAllDataKeys();
    if (keys.size() > 0) {
        scenario.write("The following data values were used in this test run:");
        for (String key: keys) {
            scenario.write("{" + key + "} => " + driverWrapper.getData(key));
        }
    }
}
 
開發者ID:dvsa,項目名稱:mot-automated-testsuite,代碼行數:15,代碼來源:LifecycleHooks.java

示例6: embedScreenshot

import cucumber.api.Scenario; //導入方法依賴的package包/類
private void embedScreenshot(final Scenario result) {
	try {
		final byte[] screenshot = this.driver.getScreenshotAs(OutputType.BYTES);
		result.embed(screenshot, "image/png");
	} catch (final UnsupportedOperationException somePlatformsDontSupportScreenshots) {
		System.err.println(somePlatformsDontSupportScreenshots.getMessage());
	} catch (final WebDriverException e) {
		result.write("WARNING. Failed take screenshots with exception:" + e.getMessage());
	}
}
 
開發者ID:orionhealth,項目名稱:XBDD,代碼行數:11,代碼來源:WebDriverHook.java

示例7: populate

import cucumber.api.Scenario; //導入方法依賴的package包/類
public void populate(Scenario scenario) {
    for (Data data : embedded) {
        scenario.embed(data.data, data.mimeType);
    }
    for (String text : texts) {
        scenario.write(text);
    }
}
 
開發者ID:viltgroup,項目名稱:minium,代碼行數:9,代碼來源:ScenarioDTO.java


注:本文中的cucumber.api.Scenario.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。