本文整理匯總了Java中cucumber.api.Scenario.embed方法的典型用法代碼示例。如果您正苦於以下問題:Java Scenario.embed方法的具體用法?Java Scenario.embed怎麽用?Java Scenario.embed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cucumber.api.Scenario
的用法示例。
在下文中一共展示了Scenario.embed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
}
}
示例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());
}
}
}
示例3: tearDown
import cucumber.api.Scenario; //導入方法依賴的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();
}
示例4: 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());
}
}
示例5: afterClass
import cucumber.api.Scenario; //導入方法依賴的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();
}
示例6: afterScenario
import cucumber.api.Scenario; //導入方法依賴的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();
}
示例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);
}
}
示例8: takeScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
/**
* Indicates a driver that can capture a screenshot and store it in different ways.
*
* @param scenario
* is instance of {link cucumber.api.Scenario}
*/
public static void takeScreenshot(Scenario scenario) {
if (!DriverFactory.HTMLUNIT.equals(Context.getBrowser())) {
final byte[] screenshot = ((TakesScreenshot) Context.getDriver()).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} else {
logger.warn(Messages.getMessage(UTILITIES_ERROR_TAKING_SCREENSHOT), Context.getBrowser());
}
}
示例9: takeScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
/**
* Take a screenshot of the current browser window, and outputs it to the report, which gets picked up by the
* Cucumber default reports and reporting plugins.
* <p>Note: most Selenium web drivers, especially Chrome, only output the visible portion of the screen.</p>
* @param scenario The current scenario
*/
private void takeScreenshot(Scenario scenario) {
byte[] screenshot = driverWrapper.takeScreenshot();
if (screenshot != null ) {
scenario.embed(screenshot, "image/png");
}
}
示例10: tearDown
import cucumber.api.Scenario; //導入方法依賴的package包/類
@After
public void tearDown(Scenario scenario) {
try {
if (scenario.isFailed()) {
final byte[] screenshot = appiumDriver
.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
appiumDriver.quit();
appiumService.stop();
} catch (Exception e) {
System.out.println("Exception while running Tear down :" + e.getMessage());
}
}
示例11: takeScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
/**
* Если сценарий завершился со статусом "fail" будет создан скриншот и сохранен в директорию
* {@code <project>/build/reports/tests}
*
* @param scenario текущий сценарий
*/
@After(order = 20)
public void takeScreenshot(Scenario scenario) {
if (scenario.isFailed()) {
AkitaScenario.sleep(1);
final byte[] screenshot = ((TakesScreenshot) getWebDriver()).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
}
示例12: embedScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
@After
public void embedScreenshot(Scenario scenario) {
try {
byte[] screenshot = getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
System.err.println(somePlatformsDontSupportScreenshots.getMessage());
}
}
開發者ID:natritmeyer,項目名稱:cucumber-jvm-java-maven-parallel-picocontainer-selenium-webdriver-pagefactory-skeleton,代碼行數:10,代碼來源:SharedDriver.java
示例13: tearDown
import cucumber.api.Scenario; //導入方法依賴的package包/類
@After
public void tearDown(Scenario scenario) {
if (scenario.isFailed()) {
final byte[] screenShot = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.BYTES);
scenario.embed(screenShot, "image/png");
}
}
示例14: embedScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
@After
public void embedScreenshot(Scenario scenario) {
try {
byte[] screenshot = getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
LOGGER.error(somePlatformsDontSupportScreenshots.getMessage());
}
}
示例15: makeScreenshot
import cucumber.api.Scenario; //導入方法依賴的package包/類
public static void makeScreenshot(WebDriver driver, Scenario scenario) {
LOG.debug("Capturing screenshot for scenario {}", scenario.getName());
if (driver instanceof TakesScreenshot) {
TakesScreenshot screenshotableDriver = (TakesScreenshot) driver;
try {
byte[] screenshot = screenshotableDriver.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
} catch (WebDriverException somePlatformsDontSupportScreenshots) {
LOG.error(somePlatformsDontSupportScreenshots.getMessage());
}
} else {
LOG.warn("This web driver implementation {} cannot create screenshots", driver.getClass().getName());
}
}