當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。