Java 类org.openqa.selenium.Dimension 实例源码
项目:che
文件:SeleniumWebDriver.java
private RemoteWebDriver doCreateDriver(URL webDriverUrl) {
DesiredCapabilities capability;
switch (browser) {
case GOOGLE_CHROME:
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--dns-prefetch-disable");
capability = DesiredCapabilities.chrome();
capability.setCapability(ChromeOptions.CAPABILITY, options);
break;
default:
capability = DesiredCapabilities.firefox();
capability.setCapability("dom.max_script_run_time", 240);
capability.setCapability("dom.max_chrome_script_run_time", 240);
}
RemoteWebDriver driver = new RemoteWebDriver(webDriverUrl, capability);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
}
项目:phoenix.webui.framework
文件:TargetElementMark.java
@Override
public void mark(WebElement ele, File file) throws IOException
{
BufferedImage bufImg = ImageIO.read(file);
try
{
WebElement webEle = (WebElement) ele;
Point loc = webEle.getLocation();
Dimension size = webEle.getSize();
Graphics2D g = bufImg.createGraphics();
g.setColor(Color.red);
g.drawRect(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
}
catch(StaleElementReferenceException se)
{
}
}
项目:marathonv5
文件:JavaDriverTest.java
public void windowSetSize() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
Window window = driver.manage().window();
Dimension actual = window.getSize();
AssertJUnit.assertNotNull(actual);
java.awt.Dimension expected = EventQueueWait.call(frame, "getSize");
AssertJUnit.assertEquals(expected.width, actual.width);
AssertJUnit.assertEquals(expected.height, actual.height);
window.setSize(new Dimension(expected.width * 2, expected.height * 2));
actual = window.getSize();
AssertJUnit.assertEquals(expected.width * 2, actual.width);
AssertJUnit.assertEquals(expected.height * 2, actual.height);
}
项目:WebAndAppUITesting
文件:IphoneBaseOpt.java
/**
* 判断要点击的元素是否被其它元素覆盖
*
* @param clickBy
* @param coverBy
* @return
*/
public boolean isCover(By clickBy, By coverBy) {
MobileElement clickElement = getDriver().findElement(clickBy);
MobileElement coverElement = getDriver().findElement(coverBy);
// 获取控件开始位置高度
Point clickstart = clickElement.getLocation();
int clickStartY = clickstart.y;
Point coverstart = coverElement.getLocation();
int coverStartY = coverstart.y;
// 获取控件高度
Dimension firstq = clickElement.getSize();
int height = firstq.getHeight();
// 控件中间高度是否大于底部高度
if (clickStartY + height / 2 >= coverStartY) {
return true;
}
return false;
}
项目:WebAndAppUITesting
文件:AndroidBaseOpt.java
/**
* 判断要点击的元素是否被其它元素覆盖
*
* @param clickBy
* @param coverBy
* @return
*/
public boolean isCover(By clickBy, By coverBy) {
MobileElement clickElement = getDriver().findElement(clickBy);
MobileElement coverElement = getDriver().findElement(coverBy);
// 获取控件开始位置高度
Point clickstart = clickElement.getLocation();
int clickStartY = clickstart.y;
Point coverstart = coverElement.getLocation();
int coverStartY = coverstart.y;
// 获取控件高度
Dimension firstq = clickElement.getSize();
int height = firstq.getHeight();
// 控件中间高度是否大于底部高度
if (clickStartY + height / 2 >= coverStartY) {
return true;
}
return false;
}
项目:coteafs-appium
文件:DeviceActions.java
private TouchAction swipeTo (final SwipeDirection direction, final SwipeDistance distance) {
final Dimension size = this.driver.manage ()
.window ()
.getSize ();
final int startX = size.getWidth () / 2;
final int startY = size.getHeight () / 2;
final int endX = (int) (startX * direction.getX () * distance.getDistance ());
final int endY = (int) (startY * direction.getY () * distance.getDistance ());
final int beforeSwipe = this.device.getSetting ()
.getDelayBeforeSwipe ();
final int afterSwipe = this.device.getSetting ()
.getDelayAfterSwipe ();
final TouchAction returnAction = new TouchAction (this.driver);
returnAction.press (startX, startY)
.waitAction (ofSeconds (beforeSwipe))
.moveTo (endX, endY)
.waitAction (ofSeconds (afterSwipe))
.release ();
return returnAction;
}
项目:opentest
文件:AppiumTestAction.java
protected void swipeDown(MobileElement element) {
Point point = element.getLocation();
Dimension size = driver.manage().window().getSize();
int screenHeight = (int) (size.height * 0.90);
int elementY = point.getY();
int endX = 0;
int endY = ((int) screenHeight - elementY);
// Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
// Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
// Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
// Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
TouchAction action = new TouchAction((MobileDriver) driver);
//action.press(element).moveTo(endX, endY).release().perform();
action.press(element.getCenter().getX(), element.getCenter().getY()).moveTo(endX, screenHeight - element.getCenter().getY()).release().perform();
}
项目:opentest
文件:AppiumTestAction.java
protected void swipeRight(MobileElement element) {
Point point = element.getLocation();
Point p = element.getCenter();
Dimension size = driver.manage().window().getSize();
int screenWidth = (int) (size.width * 0.90);
// int elementX = point.getX();
int elementX = p.getX();
int endY = 0;
int endX = element.getSize().getWidth();
// Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
// Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
// Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
// Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
TouchAction action = new TouchAction((MobileDriver) driver);
//action.press(element).moveTo(endX, endY).release().perform();
action.press((int) (point.getX() + (element.getSize().getWidth() * 0.10)), element.getCenter().getY()).moveTo((int) (screenWidth - (point.getX() + (element.getSize().getWidth() * 0.10))), endY).release().perform();
}
项目:xtf
文件:WebDriverService.java
private WebDriver createWebDriver(final Consumer<DesiredCapabilities> desiredCapabilities) {
String hostName = GhostDriverService.get().getHostName();
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
if (desiredCapabilities != null) {
desiredCapabilities.accept(capabilities);
}
try {
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:" + GhostDriverService.get().getLocalPort() + "/"), capabilities);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
} catch (MalformedURLException e) {
throw new IllegalStateException("Wrong hostName '" + hostName + "', possibly GhostDriverService::start not called ", e);
}
}
项目:Cognizant-Intelligent-Test-Scripter
文件:Basic.java
@Action(object = ObjectType.BROWSER, desc = "Changes the browser size into [<Data>]", input = InputType.YES)
public void setBrowserSize() {
try {
if (Data.matches("\\d*(x|,| )\\d*")) {
String size = Data.replaceFirst("(x|,| )", " ");
String[] sizes = size.split(" ", 2);
Driver.manage().window().setSize(new Dimension(Integer.parseInt(sizes[0]), Integer.parseInt(sizes[1])));
Report.updateTestLog(Action, " Browser is resized to " + Data,
Status.DONE);
} else {
Report.updateTestLog(Action, " Invalid Browser size [" + Data + "]",
Status.DEBUG);
}
} catch (Exception ex) {
Report.updateTestLog(Action, "Unable to resize the Window ",
Status.FAIL);
Logger.getLogger(Basic.class.getName()).log(Level.SEVERE, null, ex);
}
}
项目:mobileAutomation
文件:Driver.java
/**
* Swipe from xStart to xStop on the horizontal center of the screen.
*
* @param xStart - start point in percents
* @param xStop - end point in percents
* @param speed - swipe speed
*/
public static void horizontalSwipe(double xStart, double xStop, int speed)
{
Dimension size = driver.manage().window().getSize();
((AppiumDriver<?>) driver).swipe(
// start point
(int)xStart,
size.height/2,
// end point
(int)xStop,
size.height/2,
speed);
ThreadUtils.sleepQuiet(2000);
}
项目:mobileAutomation
文件:Driver.java
/**
* Swipe from yStart to yStop on the vertical center of the screen.
*
* @param yStart - start point in percents
* @param yStop - end point in percents
* @param speed - swipe speed
*/
public static void verticalSwipe(double yStart, double yStop, int speed)
{
Dimension size = driver.manage().window().getSize();
((AppiumDriver<?>) driver).swipe(
// start point
size.width/2,
(int)(size.height*yStart),
// end point
size.width/2,
(int)(size.height*yStop),
speed);
ThreadUtils.sleepQuiet(2000);
}
项目:bobcat
文件:DroppableWebElement.java
/**
* @return Point in the middle of the drop area.
*/
@Override
public Point getCurrentLocation() {
Point inViewPort = null;
switcher.switchTo(getFramePath());
try {
Dimension size = dropArea.getSize();
inViewPort = ((Locatable) dropArea).getCoordinates().inViewPort()
.moveBy(size.getWidth() / 2, size.getHeight() / 2);
} finally {
switcher.switchBack();
}
return inViewPort;
}
项目:xframium-java
文件:ReportingWebElementAdapter.java
@Override
public Dimension getSize()
{
Dimension returnValue = null;
webDriver.getExecutionContext().startStep( createStep( "AT" ), null, null );
try
{
returnValue = baseElement.getSize();
}
catch( Exception e )
{
webDriver.getExecutionContext().completeStep( StepStatus.FAILURE, e );
}
webDriver.getExecutionContext().completeStep( StepStatus.SUCCESS, null );
return returnValue;
}
项目:xframium-java
文件:CachedWebElement.java
@Override
public Dimension getSize()
{
try
{
String height = null, width = null;
height=getAttribute( "height" );
width=getAttribute( "width" );
if ( height != null && width != null )
return new Dimension( Integer.parseInt( width ), Integer.parseInt( height ) );
else
return new Dimension( 0, 0 );
}
catch( Exception e )
{
return webDriver.findElement( by ).getSize();
}
}
项目:xframium-java
文件:DeviceWebDriver.java
public void get( String url )
{
setLastAction();
webDriver.get( url );
try
{
double outerHeight = Integer.parseInt( executeScript( "return window.outerHeight;" ) + "" );
double outerWidth = Integer.parseInt( executeScript( "return window.outerWidth;" ) + "" );
Dimension windowSize = manage().window().getSize();
Object f = executeScript( "return window.outerHeight;" );
heightModifier = (double) windowSize.getHeight() / outerHeight;
widthModifier = (double) windowSize.getWidth() / outerWidth;
}
catch( Exception e )
{
log.warn( "Could not extract height/width modifiers" );
heightModifier = 1;
widthModifier = 1;
}
}
项目:xframium-java
文件:SELENIUMCloudActionProvider.java
@Override
public boolean popuplateDevice( DeviceWebDriver webDriver, String deviceId, Device device, String xFID )
{
String uAgent = (String) webDriver.executeScript("return navigator.userAgent;");
UserAgent userAgent = new UserAgent( uAgent );
device.setBrowserName( userAgent.getBrowser().getName() );
device.setManufacturer( userAgent.getOperatingSystem().getManufacturer().getName() );
String[] osSplit = userAgent.getOperatingSystem().getName().split( " " );
device.setOs( osSplit[ 0 ].toUpperCase() );
if ( osSplit.length > 1 )
device.setOsVersion( userAgent.getOperatingSystem().getName().split( " " )[ 1 ].toUpperCase() );
Dimension winDim = webDriver.manage().window().getSize();
if ( winDim != null )
device.setResolution( winDim.getWidth() + " x " + winDim.height );
else
device.setResolution( null );
return true;
}
项目:xframium-java
文件:SAUCELABSCloudActionProvider.java
@Override
public boolean popuplateDevice( DeviceWebDriver webDriver, String deviceId, Device device, String xFID )
{
String uAgent = (String) webDriver.executeScript("return navigator.userAgent;");
UserAgent userAgent = new UserAgent( uAgent );
device.setBrowserName( userAgent.getBrowser().getName() );
device.setManufacturer( userAgent.getOperatingSystem().getManufacturer().getName() );
String[] osSplit = userAgent.getOperatingSystem().getName().split( " " );
device.setOs( osSplit[ 0 ].toUpperCase() );
if ( osSplit.length > 1 )
device.setOsVersion( userAgent.getOperatingSystem().getName().split( " " )[ 1 ].toUpperCase() );
Dimension winDim = webDriver.manage().window().getSize();
if ( winDim != null )
device.setResolution( winDim.getWidth() + " x " + winDim.height );
else
device.setResolution( null );
return true;
}
项目:xframium-java
文件:PressGesture.java
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
AppiumDriver appiumDriver = null;
if ( webDriver instanceof AppiumDriver )
appiumDriver = (AppiumDriver) webDriver;
else if ( webDriver instanceof NativeDriverProvider )
{
NativeDriverProvider nativeProvider = (NativeDriverProvider) webDriver;
if ( nativeProvider.getNativeDriver() instanceof AppiumDriver )
appiumDriver = (AppiumDriver) nativeProvider.getNativeDriver();
else
throw new IllegalArgumentException( "Unsupported Driver Type " + webDriver );
}
Dimension screenDimension = appiumDriver.manage().window().getSize();
Point pressPosition = getActualPoint( getPressPosition(), screenDimension );
TouchAction swipeAction = new TouchAction( appiumDriver );
swipeAction.press( pressPosition.getX(), pressPosition.getY() ).waitAction( Duration.ofMillis( getPressLength() ) ).release().perform();
return true;
}
项目:xframium-java
文件:SwipeGesture.java
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
AppiumDriver appiumDriver = null;
if ( webDriver instanceof AppiumDriver )
appiumDriver = (AppiumDriver) webDriver;
else if ( webDriver instanceof NativeDriverProvider )
{
NativeDriverProvider nativeProvider = (NativeDriverProvider) webDriver;
if ( nativeProvider.getNativeDriver() instanceof AppiumDriver )
appiumDriver = (AppiumDriver) nativeProvider.getNativeDriver();
else
throw new IllegalArgumentException( "Unsupported Driver Type " + webDriver );
}
Dimension screenDimension = appiumDriver.manage().window().getSize();
Point actualStart = getActualPoint( getSwipeStart(), screenDimension );
Point actualEnd = getActualPoint( getSwipeEnd(), screenDimension );
TouchAction swipeAction = new TouchAction( appiumDriver );
swipeAction.press( actualStart.getX(), actualStart.getY() ).moveTo( actualEnd.getX(), actualEnd.getY() ).release().perform();
return true;
}
项目:xframium-java
文件:NumberPickerSetMethod.java
private void clickAt( WebElement webElement, WebDriver webDriver, int x, int y )
{
if ( webElement != null )
{
Dimension elementSize = webElement.getSize();
int useX = (int) ((double) elementSize.getWidth() * ((double) x / 100.0));
int useY = (int) ((double) elementSize.getHeight() * ((double) y / 100.0));
if ( ((DeviceWebDriver) webDriver).getNativeDriver() instanceof AppiumDriver )
{
new TouchAction( (AppiumDriver) ((DeviceWebDriver) webDriver).getNativeDriver() ).moveTo( webElement ).tap( webElement, useX, useY ).perform();
}
else if ( ((DeviceWebDriver) webDriver).getNativeDriver() instanceof RemoteWebDriver )
{
if ( ((DeviceWebDriver) webDriver).getNativeDriver() instanceof HasTouchScreen )
new TouchActions( webDriver ).moveToElement( webElement, useX, useY ).click().build().perform();
else
new Actions( webDriver ).moveToElement( webElement, useX, useY ).click().build().perform();
}
}
}
项目:menggeqa
文件:AppiumDriver.java
/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the
* screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element, if this would
* happen to place one of them off the screen, appium with return an outOfBounds error.
* In this case, revert to using the MultiTouchAction api instead of this method.
*
* @param el The element to pinch.
*/
public void pinch(WebElement el) {
MultiTouchAction multiTouch = new MultiTouchAction(this);
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();
TouchAction action0 =
new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el)
.release();
TouchAction action1 =
new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el)
.release();
multiTouch.add(action0).add(action1);
multiTouch.perform();
}
项目:menggeqa
文件:AppiumDriver.java
/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding
* away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen
* to place one of them off the screen, appium will return an outOfBounds error.
* In this case, revert to using the MultiTouchAction api instead of this method.
*
* @param el The element to pinch.
*/
public void zoom(WebElement el) {
MultiTouchAction multiTouch = new MultiTouchAction(this);
Dimension dimensions = el.getSize();
Point upperLeft = el.getLocation();
Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
upperLeft.getY() + dimensions.getHeight() / 2);
int yOffset = center.getY() - upperLeft.getY();
TouchAction action0 = new TouchAction(this).press(center.getX(), center.getY())
.moveTo(el, center.getX(), center.getY() - yOffset).release();
TouchAction action1 = new TouchAction(this).press(center.getX(), center.getY())
.moveTo(el, center.getX(), center.getY() + yOffset).release();
multiTouch.add(action0).add(action1);
multiTouch.perform();
}
项目:awplab-core
文件:SeleniumProvider.java
@Override
public AutoClosableWebDriver wrapDriver(WebDriver webDriver) {
AutoClosableWebDriver autoClosableWebDriver = new AutoClosableWebDriver(webDriver);
if (waitUntilTimeout != null && waitUntilTimeoutUnit != null) {
autoClosableWebDriver.setDefaultWaitUntilTimeout(waitUntilTimeout);
autoClosableWebDriver.setDefaultWaitUntilTimeoutUnit(TimeUnit.valueOf(waitUntilTimeoutUnit));
}
if (implicityWaitTime != null && implicityWaitTimeUnit != null) {
autoClosableWebDriver.manage().timeouts().implicitlyWait(implicityWaitTime, TimeUnit.valueOf(implicityWaitTimeUnit));
}
if (pageLoadTimeout != null && pageLoadTimeoutUnit != null) {
autoClosableWebDriver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.valueOf(pageLoadTimeoutUnit));
}
if (scriptTimeout != null && scriptTimeoutUnit != null) {
autoClosableWebDriver.manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.valueOf(scriptTimeoutUnit));
}
if (windowHeight != null && windowWidth != null) {
autoClosableWebDriver.manage().window().setSize(new Dimension(windowWidth, windowHeight));
}
return autoClosableWebDriver;
}
项目:alimama
文件:SeleniumUtil.java
public static BufferedImage createElementImage(WebDriver driver,WebElement webElement)
throws IOException {
try{
// 获得webElement的位置和大小。
Point location = webElement.getLocation();
Dimension size = webElement.getSize();
// 创建全屏截图。
BufferedImage originalImage =
ImageIO.read(new ByteArrayInputStream(takeScreenshot(driver)));
// 截取webElement所在位置的子图。
BufferedImage croppedImage = originalImage.getSubimage(
location.getX(),
location.getY(),
size.getWidth(),
size.getHeight());
return croppedImage;
}catch(Exception e){
e.printStackTrace();
}
return null;
}
项目:aet
文件:ScreenCollector.java
private byte[] getImagePart(byte[] fullPage, WebElement webElement)
throws IOException, ProcessingException {
InputStream in = new ByteArrayInputStream(fullPage);
try {
BufferedImage fullImg = ImageIO.read(in);
Point point = webElement.getLocation();
Dimension size = webElement.getSize();
BufferedImage screenshotSection = fullImg.getSubimage(point.getX(), point.getY(),
size.getWidth(), size.getHeight());
return bufferedImageToByteArray(screenshotSection);
} catch (IOException e) {
throw new ProcessingException("Unable to create image from taken screenshot", e);
} finally {
IOUtils.closeQuietly(in);
}
}
项目:hugegherkin
文件:BrowserClass.java
/**
* Example: =1204,1024
*/
@Autowired
public BrowserClass(@Value("${browser.web}") final String browserWebPropertyStr,
@Value("${browser.tablet}") final String browserTabletPropertyStr,
@Value("${browser.mobile}") final String browserMobilePropertyStr,
@Value("${browser.phantom}") final String browserPhantomPropertyStr) {
List<Integer> browserWebProperty = stringToInts(browserWebPropertyStr);
List<Integer> browserTabletProperty = stringToInts(browserTabletPropertyStr);
List<Integer> browserMobileProperty = stringToInts(browserMobilePropertyStr);
List<Integer> browserPhantomProperty = stringToInts(browserPhantomPropertyStr);
browserClassMap.put(BrowserType.WEB, new Dimension(browserWebProperty.get(0), browserWebProperty.get(1)));
browserClassMap.put(BrowserType.TABLET, new Dimension(browserTabletProperty.get(0), browserTabletProperty.get(1)));
browserClassMap.put(BrowserType.MOBILE, new Dimension(browserMobileProperty.get(0), browserMobileProperty.get(1)));
browserClassMap.put(BrowserType.PHANTOM, new Dimension(browserPhantomProperty.get(0), browserPhantomProperty.get(1)));
}
项目:che
文件:TestWebElementRenderChecker.java
private void waitElementIsStatic(FluentWait<WebDriver> webDriverWait, WebElement webElement) {
AtomicInteger sizeHashCode = new AtomicInteger();
webDriverWait.until(
(ExpectedCondition<Boolean>)
driver -> {
Dimension newDimension = waitAndGetWebElement(webElement).getSize();
if (dimensionsAreEquivalent(sizeHashCode, newDimension)) {
return true;
} else {
sizeHashCode.set(getSizeHashCode(newDimension));
return false;
}
});
}
项目:web-test-framework
文件:TestCaseContextTest.java
/**
*
*/
@Test(groups = "local")
public void testSetWindowSize() {
DriverFactory factory = new DriverFactory();
Dimension dimension = new Dimension(400, 600);
TestCaseContext context = new TestCaseContext();
context.parameters()
.setBrowserVersionPlatform(BrowserVersionPlatform.WIN7FF)
.setWindowSize(dimension);
context.setDriverFactory(factory);
Driver driver = context.getDriver();
Dimension actualDimension = driver.manage().window().getSize();
Assert.assertEquals(actualDimension.height, dimension.height);
Assert.assertEquals(actualDimension.width, dimension.width);
driver.quit();
}
项目:edx-app-android
文件:NativeAppDriver.java
/**
* Wait till the element is displayed and swipe till the particular time
* slot
*
* @param id
* - id of the element
*/
public void swipe(String id) {
try {
if (isAndroid()) {
new WebDriverWait(appiumDriver, 20).until(ExpectedConditions
.presenceOfElementLocated(By.id(id)));
Dimension dimension = appiumDriver.manage().window().getSize();
int ht = dimension.height;
int width = dimension.width;
appiumDriver.swipe((width / 2), (ht / 4), (width / 2),
(ht / 2), 1000);
} else {
new WebDriverWait(appiumDriver, 20).until(ExpectedConditions
.presenceOfElementLocated(By.id(id)));
if (deviceName.equalsIgnoreCase("iphone 5")) {
appiumDriver.swipe((int) 0.1, 557, 211, 206, 500);
} else if (deviceName.equalsIgnoreCase("iphone 6")) {
appiumDriver.swipe((int) 0.1, 660, 50, 50, 500);
}
}
} catch (Throwable e) {
Reporter.log("Element by Id " + id + " not visible");
captureScreenshot();
throw e;
}
}
项目:appformer
文件:PerspectiveSaveRestoreTest.java
@Test
public void testResizeWestPanel() throws Exception {
WebElement splitterDragHandle = driver.findElement(By.className("gwt-SplitLayoutPanel-HDragger"));
Actions dragAndDrop = new Actions(driver);
dragAndDrop.dragAndDropBy(splitterDragHandle,
123,
0);
dragAndDrop.perform();
ResizeWidgetWrapper westScreen = new ResizeWidgetWrapper(driver,
"west");
Dimension westScreenNewSize = westScreen.getReportedSize();
driver.get(baseUrl + "#" + DefaultPerspectiveActivity.class.getName());
waitForDefaultPerspective();
driver.get(baseUrl + "#" + NonTransientMultiPanelPerspective.class.getName());
ResizeWidgetWrapper westScreenReloaded = new ResizeWidgetWrapper(driver,
"west");
assertEquals(westScreenNewSize,
westScreenReloaded.getReportedSize());
}
项目:appformer
文件:WorkbenchResizeTest.java
@Test
public void testListPerspectiveSizeWithNestedPanels() throws Exception {
driver.get(baseUrl + "#" + ListPerspectiveActivity.class.getName());
ResizeWidgetWrapper widgetWrapper = new ResizeWidgetWrapper(driver,
"listPerspectiveDefault");
TopHeaderWrapper topHeaderWrapper = new TopHeaderWrapper(driver);
topHeaderWrapper.addPanelToRoot(CompassPosition.WEST,
MultiListWorkbenchPanelPresenter.class,
ResizeTestScreenActivity.class,
"id",
"resize1");
Dimension sizeAfterWestPanelAdded = widgetWrapper.getActualSize();
topHeaderWrapper.addPanelToRoot(CompassPosition.EAST,
MultiListWorkbenchPanelPresenter.class,
ResizeTestScreenActivity.class,
"id",
"resize2");
Dimension sizeAfterBothPanelsAdded = widgetWrapper.getActualSize();
assertTrue(sizeAfterWestPanelAdded.width < WINDOW_WIDTH);
assertTrue(sizeAfterBothPanelsAdded.width < sizeAfterWestPanelAdded.width);
}
项目:appformer
文件:MaximizePanelTest.java
@Test
public void maximizeButtonShouldWorkOnTabbedPanel() throws Exception {
MaximizeTestScreenWrapper tabPanelScreen4 =
new MaximizeTestScreenWrapper(driver,
MaximizeTestPerspective.TAB_PANEL_SCREEN_4_ID);
Dimension reportedSizeBefore = tabPanelScreen4.getReportedSize();
tabPanel.clickMaximizeButton();
Dimension reportedSizeAfter = tabPanelScreen4.getReportedSize();
assertBigger(reportedSizeBefore,
reportedSizeAfter);
assertObscuredBy(tabPanel,
listPanel);
assertObscuredBy(tabPanel,
simplePanel);
}
项目:appformer
文件:MaximizePanelTest.java
@Test
public void maximizeButtonShouldWorkOnListPanel() throws Exception {
MaximizeTestScreenWrapper listPanelScreen2 =
new MaximizeTestScreenWrapper(driver,
MaximizeTestPerspective.LIST_PANEL_SCREEN_2_ID);
Dimension reportedSizeBefore = listPanelScreen2.getReportedSize();
listPanel.clickMaximizeButton();
Dimension reportedSizeAfter = listPanelScreen2.getReportedSize();
assertBigger(reportedSizeBefore,
reportedSizeAfter);
assertObscuredBy(listPanel,
tabPanel);
assertObscuredBy(listPanel,
simplePanel);
}
项目:appformer
文件:MaximizePanelTest.java
@Test
public void maximizeButtonShouldWorkOnSimplePanel() throws Exception {
MaximizeTestScreenWrapper simplePanelScreen5 =
new MaximizeTestScreenWrapper(driver,
MaximizeTestPerspective.SIMPLE_PANEL_SCREEN_5_ID);
Dimension reportedSizeBefore = simplePanelScreen5.getReportedSize();
simplePanel.clickMaximizeButton();
Thread.sleep(3000);
Dimension reportedSizeAfter = simplePanelScreen5.getReportedSize();
assertBigger(reportedSizeBefore,
reportedSizeAfter);
assertObscuredBy(simplePanel,
tabPanel);
assertObscuredBy(simplePanel,
listPanel);
}
项目:appformer
文件:MaximizePanelTest.java
@Test
public void maximizedTabPanelShouldTrackWindowSize() throws Exception {
MaximizeTestScreenWrapper tabPanelScreen4 =
new MaximizeTestScreenWrapper(driver,
MaximizeTestPerspective.TAB_PANEL_SCREEN_4_ID);
tabPanel.clickMaximizeButton();
Dimension originalMaximizedSize = tabPanelScreen4.getReportedSize();
driver.manage().window().setSize(new Dimension(WINDOW_WIDTH + 50,
WINDOW_HEIGHT - 40));
new WebDriverWait(driver,
5)
.until(reportedSizeIs(tabPanelScreen4,
new Dimension(originalMaximizedSize.width + 50,
originalMaximizedSize.height - 40)));
}
项目:appformer
文件:MaximizePanelTest.java
@Test
public void maximizedListPanelShouldTrackWindowSize() throws Exception {
MaximizeTestScreenWrapper listPanelScreen2 =
new MaximizeTestScreenWrapper(driver,
MaximizeTestPerspective.LIST_PANEL_SCREEN_2_ID);
listPanel.clickMaximizeButton();
Dimension originalMaximizedSize = listPanelScreen2.getReportedSize();
driver.manage().window().setSize(new Dimension(WINDOW_WIDTH + 50,
WINDOW_HEIGHT - 40));
new WebDriverWait(driver,
5)
.until(reportedSizeIs(listPanelScreen2,
new Dimension(originalMaximizedSize.width + 50,
originalMaximizedSize.height - 40)));
}
项目:hifive-pitalium
文件:PtlWebDriverFactory.java
/**
* 初期設定(baseUrl、タイムアウト時間、ウィンドウサイズ)済のWebDriverを取得します。
*
* @return WebDriver
*/
public PtlWebDriver getDriver() {
synchronized (PtlWebDriverFactory.class) {
LOG.debug("[Get WebDriver] create new session.");
URL url = getGridHubURL();
PtlWebDriver driver = createWebDriver(url);
driver.setEnvironmentConfig(environmentConfig);
driver.setBaseUrl(testAppConfig.getBaseUrl());
driver.manage().timeouts().implicitlyWait(environmentConfig.getMaxDriverWait(), TimeUnit.SECONDS)
.setScriptTimeout(environmentConfig.getScriptTimeout(), TimeUnit.SECONDS);
if (!isMobile()) {
driver.manage().window()
.setSize(new Dimension(testAppConfig.getWindowWidth(), testAppConfig.getWindowHeight()));
}
LOG.debug("[Get WebDriver] new session created. ({})", driver);
return driver;
}
}
项目:hifive-pitalium
文件:ExcludeSingleElementTest.java
/**
* 単体要素撮影時に、小数点以下がある幅を持つ単体要素を指定して除外する。
*
* @ptl.expect 除外領域が正しく保存されていること。
*/
@Test
public void singleTestWithDecimal() {
openBasicColorPage();
driver.manage().window().setSize(new Dimension(1100, (int) driver.getWindowHeight()));
ScreenshotArgument arg = ScreenshotArgument.builder("s").addNewTarget().addExcludeById("colorColumn1").build();
assertionView.assertView(arg);
// Check
Rect rect = getRectById("colorColumn1");
TargetResult result = loadTargetResults("s").get(0);
assertThat(result.getExcludes(), hasSize(1));
RectangleArea area = result.getExcludes().get(0).getRectangle();
RectangleArea expectArea = rect.toExcludeRect().toRectangleArea();
assertThat(area, is(expectArea));
}
项目:hifive-pitalium
文件:TakeEntirePageScreenshotTest.java
/**
* 十分な高さにしてスクロールが出ない状態でbodyのtakeScreenshotを実行するテスト.<br>
* 前提条件:なし<br>
* 実行環境:IE7~11/FireFox/Chrome/Android 2.3, 4.0, 4.4/iOS 8.1<br>
* 期待結果:結果オブジェクト(ScrrenshotResult)に想定通りの値が入っている<br>
* また、全体の画像とbodyの画像が取得でき、それらをpersistすると画像ファイルが生成される。<br>
* これらの画像の内容は目視で確認を行うこと。
*
* @throws IOException
*/
@Test
public void specifyTargetBodyWithoutScroll() throws IOException {
String platformName = capabilities.getPlatformName();
if (!"iOS".equals(platformName) && !"android".equalsIgnoreCase(platformName)) {
driver.manage().window().setSize(new Dimension(1280, 2500));
}
driver.get(TEST_TOP_PAGE_URL);
PtlWebDriverWait wait = new PtlWebDriverWait(driver, 30);
wait.untilLoad();
ScreenshotResult result = driver.takeScreenshot("topPage");
assertScreenshotResult(result, "specifyTargetBodyWithoutScroll");
}