本文整理汇总了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();
}
}
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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>");
*/
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}