Skip to content

Instantly share code, notes, and snippets.

@zevnull
zevnull / ExtendedFieldDecorator.java
Created April 15, 2013 14:52
ExtendedFieldDecorator
package com.ddn.autotest.ui.primitives;
import java.lang.reflect.Field;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import org.openqa.selenium.support.pagefactory.DefaultFieldDecorator;
import org.openqa.selenium.support.pagefactory.ElementLocator;
@zevnull
zevnull / ParseImg.java
Created May 7, 2013 08:03
Parse image
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ParseImg extends Component
{
@zevnull
zevnull / Point.java
Created May 7, 2013 12:36
Create screenshot for element
BrowserFactory.getExistentWebDriver().switchTo().frame( "outerFrame" );
WebElement ele =
BrowserFactory.getExistentWebDriver().findElement( By.cssSelector( "div#sfahciops > .flot-overlay" ) );
File screenshot = ( ( TakesScreenshot ) BrowserFactory.getExistentWebDriver() ).getScreenshotAs( OutputType.FILE );
BufferedImage fullImg = ImageIO.read( screenshot );
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
@zevnull
zevnull / SolutionsOverviewUtils.java
Created May 17, 2013 06:54
Get list of Solutions Overview names from config file
/**
* Get list of Solutions Overview names from config file
*
* @return List<String> - Solutions Overview names
* @throws Exception
*/
public List<String> getSolutionsOverviewNamesFromConfig() throws Exception
{
DMLogger.methodStarted();
// TODO add path for QH DM2Web config (system-config.json)
@zevnull
zevnull / SolutionsOverviewUtils.java
Created May 17, 2013 06:56
Get list of Solutions Overview names from config file
/**
* Get list of Solutions Overview names from config file
*
* @return List<String> - Solutions Overview names
* @throws Exception
*/
public List<String> getSolutionsOverviewNamesFromConfig() throws Exception
{
DMLogger.methodStarted();
// TODO add path for QH DM2Web config (system-config.json)
@zevnull
zevnull / FileSystemView.java
Created May 18, 2013 07:35
Draft ... need refactoring !!!!
package com.ddn.autotest.ui.primitives;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
@zevnull
zevnull / SolutionsOverviewUtils.java
Created May 20, 2013 12:37
Get set of NSDs from config file
/**
* Get set of NSDs from config file
*
* @return set of NSDs from config file
*/
public Set<String> getNSDsSetFromConfig()
{
DMLogger.methodStarted();
String jsonTxt = "";
@zevnull
zevnull / UserIDElement.java
Created May 24, 2013 10:35
Element screenshot
BrowserFactory.getExistentWebDriver().switchTo().frame( "outerFrame" );
WebElement ele =
BrowserFactory.getExistentWebDriver().findElement( By.cssSelector( "canvas.flot-overlay" ) );
File screenshot = ( ( TakesScreenshot ) BrowserFactory.getExistentWebDriver() ).getScreenshotAs( OutputType.FILE );
BufferedImage fullImg = ImageIO.read( screenshot );
Point point = ele.getLocation();
int eleWidth = ele.getSize().getWidth();
int eleHeight = ele.getSize().getHeight();
switch( deviceType )
{
case HEADNODE:
return true;
case STORAGE:
for( String metric : metricsList )
{
if( metric.contains( METRIC_KEY_STORAGE ) )
specificMetricCount++;
@zevnull
zevnull / gist:6634682
Created September 20, 2013 08:23
take screenshot using Remote webdriver
public class ScreenShotRemoteWebDriver extends RemoteWebDriver implements TakesScreenshot {
public ScreenShotRemoteWebDriver(URL url, DesiredCapabilities capabilities) {
super(url, capabilities);
}
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
if ((Boolean)getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT)) {
return target.convertFromBase64Png(execute(DriverCommand.SCREENSHOT).getValue().to­String());
}
return null;
}}