当前位置: 首页>>代码示例>>Java>>正文


Java Augmenter类代码示例

本文整理汇总了Java中org.openqa.selenium.remote.Augmenter的典型用法代码示例。如果您正苦于以下问题:Java Augmenter类的具体用法?Java Augmenter怎么用?Java Augmenter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Augmenter类属于org.openqa.selenium.remote包,在下文中一共展示了Augmenter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setScreenshot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
@AfterMethod
public void setScreenshot(ITestResult result) {
  if (!result.isSuccess()) {
    try {
      WebDriver returned = new Augmenter().augment(webDriver);
      if (returned != null) {
        File f = ((TakesScreenshot) returned).getScreenshotAs(OutputType.FILE);
        try {
          FileUtils.copyFile(f,
              new File(SCREENSHOT_FOLDER + result.getName() + SCREENSHOT_FORMAT));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    } catch (ScreenshotException se) {
      se.printStackTrace();
    }
  }
}
 
开发者ID:ViliamS,项目名称:XPathBuilder,代码行数:20,代码来源:TestBase.java

示例2: tearDown

import org.openqa.selenium.remote.Augmenter; //导入依赖的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();
}
 
开发者ID:HotwireDotCom,项目名称:bdd-test-automation-for-mobile,代码行数:19,代码来源:SetupTeardownSteps.java

示例3: afterScenario

import org.openqa.selenium.remote.Augmenter; //导入依赖的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

示例4: createScreenshot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
@Override public boolean createScreenshot(WebDriverConnector wd, File screenshotFile) throws Exception {
	WebDriver ad = wd.driver();

	if(ad instanceof RemoteWebDriver && wd.getDriverType() == WebDriverType.REMOTE) {
		//for remote drivers we need to do augmenter thingy, for local we must not
		ad = new Augmenter().augment(ad);
	}

	if(ad instanceof TakesScreenshot) {
		File f = ((TakesScreenshot) ad).getScreenshotAs(OutputType.FILE);
		try {
			FileTool.copyFile(screenshotFile, f);
		} finally {
			FileTool.closeAll(f);
		}
		return true;
	}
	return false;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:20,代码来源:DefaultScreenshotHelper.java

示例5: capture

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
/**
 * 鎴浘
 * 
 * @param driver
 * @param url
 * @param filePath
 * @return
 */
public static String capture(WebDriver driver, String url, String filePath) {
	if (driver == null) {
		return null;
	}
	if (!url.startsWith("http:") && !url.startsWith("https:")) {
		return null;
	}
	if (StringUtils.isBlank(filePath)) {
		return null;
	}
	try {
		driver.get(url);
		WebDriver augmentedDriver = new Augmenter().augment(driver);
		File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
		File file = new File(filePath);
		FileUtils.copyFile(screenshot, file);
		logger.info("capture success!");
	} catch (IOException e) {
		logger.error("browser capture is error!", e);
		filePath = null;
		throw new RuntimeException(e);
	}
	return filePath;
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:33,代码来源:SeleniumUtil.java

示例6: captureDataoke

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
/**
 * 鎴浘
 * 
 * @param driver
 * @param url
 * @param filePath
 * @return
 */
public static String captureDataoke(WebDriver driver, String url, String filePath) {
	if (driver == null) {
		return null;
	}
	if (!url.startsWith("http:") && !url.startsWith("https:")) {
		return null;
	}
	if (StringUtils.isBlank(filePath)) {
		return null;
	}
	try {
		driver.get(url);
		WebDriver augmentedDriver = new Augmenter().augment(driver);
		File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
		File file = new File(filePath);
		FileUtils.copyFile(screenshot, file);
		logger.info("capture success!");
	} catch (IOException e) {
		logger.error("browser capture is error!", e);
		filePath = null;
		throw new RuntimeException(e);
	}
	return filePath;
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:33,代码来源:SeleniumUtil.java

示例7: captureScreen

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
/**
 * Tira uma foto da p�gina
 * 
 * @param path
 *            - Retorna o local que a imagem foi gravada.
 * @author Rog�rio Figueiredo.
 */

public String captureScreen(String path) {
	path = path + "\\";
	try {
		WebDriver augmentedDriver = new Augmenter().augment(driver);
		File source = ((TakesScreenshot) augmentedDriver)
				.getScreenshotAs(OutputType.FILE);
		path = path + source.getName();
		FileUtils.copyFile(source, new File(path));
	} catch (IOException e) {
		path = "Failed to capture screenshot: " + e.getMessage();
	}

	System.out.println("Local que foi gravado a imagem: " + path);
	return path;
}
 
开发者ID:confsoft,项目名称:FuncaoWeb,代码行数:24,代码来源:Nucleo.java

示例8: takeScreenshot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
/**
 * Takes screenshot of current page (as .png).
 * @param baseName name for file created (without extension),
 *                 if a file already exists with the supplied name an
 *                 '_index' will be added.
 * @return absolute path of file created.
 */
public String takeScreenshot(String baseName) {
    String result = null;

    WebDriver d = driver();

    if (!(d instanceof TakesScreenshot)) {
        d = new Augmenter().augment(d);
    }
    if (d instanceof TakesScreenshot) {
        TakesScreenshot ts = (TakesScreenshot) d;
        byte[] png = ts.getScreenshotAs(OutputType.BYTES);
        result = writeScreenshot(baseName, png);
    }
    return result;
}
 
开发者ID:fhoeben,项目名称:hsac-fitnesse-fixtures,代码行数:23,代码来源:SeleniumHelper.java

示例9: takeScreenshot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
private void takeScreenshot(String testName) throws Exception {
    WebDriver driver = getDriver();
    String screenshotDirectory = System.getProperty("screenshotDirectory");
    String screenshotAbsolutePath = screenshotDirectory + File.separator
            + System.currentTimeMillis() + "_" + testName + ".png";
    File screenshot = new File(screenshotAbsolutePath);
    if (createFile(screenshot)) {
        try {
            writeScreenshotToFile(driver, screenshot);
        } catch (ClassCastException weNeedToAugmentOurDriverObject) {
            writeScreenshotToFile(new Augmenter().augment(driver),
                    screenshot);
        }
        System.out.println("Written screenshot to "
                + screenshotAbsolutePath);
    } else {
        System.err.println("Unable to create " + screenshotAbsolutePath);
    }
}
 
开发者ID:jvanderwee,项目名称:bootstrapium,代码行数:20,代码来源:ScreenshotListener.java

示例10: onTestFailure

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
@Override
public void onTestFailure(ITestResult tr)
{
    if(DriverAdapter.getDriver() != null)
    {
        WebDriver augmentedDriver = new Augmenter().augment(DriverAdapter.getDriver());
        File screenShot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
        try
        {
            FileUtils.copyFile(screenShot, new File(System.getProperty("testReport") + "/screenshots/"+tr.getMethod().getMethodName().toLowerCase()+".jpg"));
        }
        catch(IOException e)
        {
            System.err.println(e.getMessage());
        }
    }
    log("F");
    super.onTestFailure(tr);
}
 
开发者ID:Flipkart,项目名称:harness,代码行数:20,代码来源:TestListener.java

示例11: takeScreenShot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
public static void takeScreenShot() throws Exception {
	WebDriver augmentedDriver = new Augmenter().augment(driver);
	File screenshot = ((TakesScreenshot) augmentedDriver)
			.getScreenshotAs(OutputType.FILE);
	String nameScreenshot = UUID.randomUUID().toString() + ".png";
	File directory = new File(".");

	String newFileNamePath = directory.getCanonicalPath() + pathSeparator
			+ "target" + pathSeparator + "jbehave" + pathSeparator
			+ "screenshots" + pathSeparator + nameScreenshot;
	FileUtils.copyFile(screenshot, new File(newFileNamePath));

	// return newFileNamePath;

	/*
	 * Reporter.log(message + "<br/><a href='file:///" + path +
	 * "'> <img src='file:///" + path +
	 * "' height='100' width='100'/> </a>");
	 */
}
 
开发者ID:saikrishna321,项目名称:JBehave-Selendroid-Android-Automation,代码行数:21,代码来源:CommonMethods.java

示例12: takeScreenShotFile

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
public File takeScreenShotFile(Session session) {
    boolean event = true;
    long timeout = System.currentTimeMillis() + (session.getCerberus_selenium_wait_element());
    //Try to capture picture. Try again until timeout is WebDriverException is raised.
    while (event) {
        try {
            WebDriver augmentedDriver = new Augmenter().augment(session.getDriver());
            File image = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);

            if (image != null) {
                //logs for debug purposes
                LOG.info("WebDriverService: screen-shot taken with succes: " + image.getName() + "(size" + image.length() + ")");
            } else {
                LOG.warn("WebDriverService: screen-shot returned null: ");
            }
            return image;
        } catch (WebDriverException exception) {
            if (System.currentTimeMillis() >= timeout) {
                LOG.warn(exception.toString());
            }
            event = false;
        }
    }

    return null;
}
 
开发者ID:cerberustesting,项目名称:cerberus-source,代码行数:27,代码来源:WebDriverService.java

示例13: setUpScreenshot

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
private void setUpScreenshot(String screenshotPath)
        throws IOException {
    if (Boolean.valueOf(System.getProperty("LOCAL_DRIVER"))) {
        takeScreenshot();
        writeScreenshotToFileSystem(screenshotPath);
        LOGGER.log(Level.FINEST, MESSAGE_LOCAL_SCREENSHOT_SUCCESSFUL
                + screenshotPath);
    } else if (Boolean.valueOf(System.getProperty("REMOTE_DRIVER"))) {
        driver.set(new Augmenter().augment(driver.get()));
        takeScreenshot();
        writeScreenshotToFileSystem(screenshotPath);
        LOGGER.log(Level.FINEST, MESSAGE_REMOTE_SCREENSHOT_SUCCESSFUL
                + screenshotPath);
    } else if (Boolean.valueOf(System.getProperty("SAUCE_DRIVER"))) {
        LOGGER.log(Level.WARNING, MESSAGE_SAUCE_SCREENSHOT_FAILURE);
    } else {
        LOGGER.log(Level.WARNING,
                MESSAGE_CANNOT_TAKE_SCREENSHOT_UNABLE_TO_IDENTIFY_DRIVER_TYPE);
    }
}
 
开发者ID:testworx,项目名称:SeleniumFramework,代码行数:21,代码来源:Browser.java

示例14: getScreenshotAs

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
@Override
public <X> X getScreenshotAs(OutputType<X> target) {
    if (getWebDriver().getClass() == RemoteWebDriver.class) {
        WebDriver augmentedDriver = new Augmenter().augment(getWebDriver());
        return ((TakesScreenshot) augmentedDriver).getScreenshotAs(target);
    } else {
        return ((TakesScreenshot) getWebDriver()).getScreenshotAs(target);
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:10,代码来源:BaseTeasyElement.java

示例15: getScreenshotAs

import org.openqa.selenium.remote.Augmenter; //导入依赖的package包/类
@Override
public <X> X getScreenshotAs(final OutputType<X> target) throws WebDriverException {
    if (driver.getClass() == RemoteWebDriver.class) {
        WebDriver augmentedDriver = new Augmenter().augment(driver);
        return ((TakesScreenshot) augmentedDriver).getScreenshotAs(target);
    } else {
        return ((TakesScreenshot) driver).getScreenshotAs(target);
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:10,代码来源:WebDriverDecorator.java


注:本文中的org.openqa.selenium.remote.Augmenter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。