org.openqa.selenium.Dimension Java Examples
The following examples show how to use
org.openqa.selenium.Dimension.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDriver.java From coteafs-selenium with Apache License 2.0 | 6 votes |
private void setScreen(final PlaybackSetting playback) { final ScreenState state = playback.getScreenState(); if (getPlatform() == DESKTOP) { LOG.i("Setting screen size of Browser to {}...", state); switch (state) { case FULL_SCREEN: manageWindow(Window::fullscreen); break; case MAXIMIZED: manageWindow(Window::maximize); break; case NORMAL: default: final ScreenResolution resolution = playback.getScreenResolution(); LOG.i("Setting screen resolution to [{}]...", resolution); manageWindow(w -> w.setSize(new Dimension(resolution.getWidth(), resolution.getHeight()))); manageWindow(w -> w.setPosition(new Point(0, 0))); break; } } }
Example #2
Source File: SwipeGesture.java From xframium-java with GNU General Public License v3.0 | 6 votes |
@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( PointOption.point(actualStart.getX(), actualStart.getY() ) ).moveTo( PointOption.point(actualEnd.getX(), actualEnd.getY() ) ).release().perform(); return true; }
Example #3
Source File: SAUCELABSCloudActionProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
@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; }
Example #4
Source File: DriverFactory.java From NoraUi with GNU Affero General Public License v3.0 | 6 votes |
/** * Generates a selenium webdriver following a name given in parameter. * By default a chrome driver is generated. * * @param driverName * The name of the web driver to generate * @return * An instance a web driver whose type is provided by driver name given in parameter * @throws TechnicalException * if an error occured when Webdriver setExecutable to true. */ private WebDriver generateWebDriver(String driverName) throws TechnicalException { WebDriver driver; if (IE.equals(driverName)) { driver = generateIEDriver(); } else if (CHROME.equals(driverName)) { driver = generateGoogleChromeDriver(); } else if (FIREFOX.equals(driverName)) { driver = generateFirefoxDriver(); } else { driver = generateGoogleChromeDriver(); } // As a workaround: NoraUi specify window size manually, e.g. window_size: 1920 x 1080 (instead of .window().maximize()). driver.manage().window().setSize(new Dimension(1920, 1080)); driver.manage().timeouts().implicitlyWait(IMPLICIT_WAIT, TimeUnit.MILLISECONDS); drivers.put(driverName, driver); return driver; }
Example #5
Source File: RegistrarConsoleScreenshotTest.java From nomulus with Apache License 2.0 | 6 votes |
@Test public void settingsContactEdit_setRegistryLockPassword() throws Throwable { server.runInAppEngineEnvironment( () -> { persistResource( makeRegistrarContact2() .asBuilder() .setRegistryLockEmailAddress("[email protected]") .setAllowedToSetRegistryLockPassword(true) .build()); persistResource(makeRegistrar2().asBuilder().setRegistryLockAllowed(true).build()); return null; }); driver.manage().window().setSize(new Dimension(1050, 2000)); driver.get(server.getUrl("/registrar#contact-settings/[email protected]")); Thread.sleep(1000); driver.waitForElement(By.tagName("h1")); driver.waitForElement(By.id("reg-app-btn-edit")).click(); driver.diffPage("page"); }
Example #6
Source File: IphoneBaseOpt.java From WebAndAppUITesting with GNU General Public License v3.0 | 6 votes |
/** * 判断要点击的元素是否被其它元素覆盖 * * @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; }
Example #7
Source File: AndroidBaseOpt.java From WebAndAppUITesting with GNU General Public License v3.0 | 6 votes |
/** * 判断要点击的元素是否被其它元素覆盖 * * @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; }
Example #8
Source File: PerfectoDeviceSteps.java From Quantum with MIT License | 6 votes |
/** * Performs the lo touch gesture according to the point coordinates. * * @param locator * write in format of x,y. can be in pixels or * percentage(recommended) for example 50%,50%. */ @Then("^I tap on \"(.*?)\" for \"(\\d*\\.?\\d*)\" seconds$") public static void tapElement(String locator, int seconds) { QAFExtendedWebElement myElement = new QAFExtendedWebElement(locator); Point location = myElement.getLocation(); Dimension size = myElement.getSize(); // determine location to click and convert to an appropriate string int xToClick = location.getX() + (size.getWidth() / 2); int yToClick = location.getY() + (size.getHeight() / 2); String clickLocation = xToClick + "," + yToClick; DeviceUtils.longTouch(clickLocation, seconds); }
Example #9
Source File: PressGesture.java From xframium-java with GNU General Public License v3.0 | 6 votes |
@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( PointOption.point( pressPosition.getX(), pressPosition.getY() ) ).waitAction( WaitOptions.waitOptions( Duration.ofMillis( getPressLength() ) ) ).release().perform(); return true; }
Example #10
Source File: SwipeUtils.java From coteafs-appium with Apache License 2.0 | 6 votes |
/** * @param direction * @param startPosition * @param distancePercent * @param setting * @param screenSize * @param elementSize * @param elementLocation * @param actions * @return action * @author wasiq.bhamla * @since Sep 18, 2018 8:03:55 PM */ public static <T extends TouchAction<T>> T swipeTo(final SwipeDirection direction, final SwipeStartPosition startPosition, final int distancePercent, final PlaybackSetting setting, final Dimension screenSize, final Dimension elementSize, final Point elementLocation, final T actions) { final double distance = distancePercent / 100.0; final Point source = getStartPoint(startPosition, screenSize, elementSize, elementLocation); int endX = source.getX() + (int) (source.getX() * direction.getX() * distance); int endY = source.getY() + (int) (source.getY() * direction.getY() * distance); if (elementSize != null) { endX = source.getX() + (int) (elementSize.getWidth() * direction.getX() * distance); endY = source.getY() + (int) (elementSize.getHeight() * direction.getY() * distance); } return actions.press(PointOption.point(source.getX(), source.getY())) .waitAction(WaitOptions.waitOptions(Duration.ofMillis(setting.getDelayBeforeSwipe()))) .moveTo(PointOption.point(endX, endY)) .release(); }
Example #11
Source File: UploadUncompilableClassTest.java From CodeDefenders with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { ChromeOptions options = new ChromeOptions(); // This is hardcoded but we cannot do otherwise. The alternative would // be to run a docker grid driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // Many suggests to define the size, but if you tests requires a // different setting, change this driver.manage().window().setSize(new Dimension(1024, 768)); // ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector()); // This is important: docker-compose randomly assign ports and names to // those logical entities so we get them from the rule String codeDefendersHome = "http://frontend:8080/codedefenders"; // // driver.get(codeDefendersHome); }
Example #12
Source File: ReadElementAspect.java From opentest with MIT License | 6 votes |
@Override public void run() { super.run(); By locator = this.readLocatorArgument("locator"); WebElement element = this.getElement(locator); Point point = element.getLocation(); int x = point.getX(); int y = point.getY(); Dimension size = element.getSize(); int width = size.width; int height = size.height; this.writeOutput("x", x); this.writeOutput("y", y); this.writeOutput("width", width); this.writeOutput("height", height); }
Example #13
Source File: Basic.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
@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); } }
Example #14
Source File: ReadElementAspect.java From opentest with MIT License | 6 votes |
@Override public void run() { super.run(); By locator = readLocatorArgument("locator"); this.swipeAndCheckElementVisible(locator, this.getSwipeOptions()); MobileElement element = this.getElement(locator); Point point = element.getLocation(); int x = point.getX(); int y = point.getY(); Dimension size = element.getSize(); int width = size.width; int height = size.height; Logger.trace(String.format("The element aspect is (%s,%s,%s,%s)", x, y, width, height)); this.writeOutput("x", x); this.writeOutput("y", y); this.writeOutput("width", width); this.writeOutput("height", height); }
Example #15
Source File: RegistrarConsoleScreenshotTest.java From nomulus with Apache License 2.0 | 6 votes |
@Test public void settingsSecurityWithCerts() throws Throwable { server.runInAppEngineEnvironment( () -> { persistResource( loadRegistrar("TheRegistrar") .asBuilder() .setClientCertificate(CertificateSamples.SAMPLE_CERT, START_OF_TIME) .setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, START_OF_TIME) .build()); return null; }); driver.manage().window().setSize(new Dimension(1050, 2000)); driver.get(server.getUrl("/registrar#security-settings")); driver.waitForElement(By.tagName("h1")); driver.diffPage("view"); driver.waitForElement(By.id("reg-app-btn-edit")).click(); driver.waitForElement(By.tagName("h1")); driver.diffPage("edit"); }
Example #16
Source File: CompareEntirePageTest.java From hifive-pitalium with Apache License 2.0 | 6 votes |
/** * 十分な高さにしてスクロールが出ない状態でbodyのassertViewを実行するテスト.<br> * 前提条件:なし<br> * 実行環境:IE7~11/FireFox/Chrome/Android 2.3, 4.0, 4.4/iOS 8.1<br> * 期待結果:実行したタイムスタンプのフォルダ内にspecifyTargetBodyWithoutScroll_topPage_WINDOWS_(browser name).pngが生成される<br> * 仕様通りのresult.jsonと座標用のjsonファイルが生成される<br> * RUN_TESTモードの場合、assertViewの比較で一致し、compareResultがtrueとなる */ @Test public void specifyTargetBodyWithoutScroll() { String platformName = capabilities.getPlatformName(); if (!"iOS".equals(platformName) && !"android".equalsIgnoreCase(platformName)) { driver.manage().window().setSize(new Dimension(1280, 2500)); } driver.get(URL_TOP_PAGE); PtlWebDriverWait wait = new PtlWebDriverWait(driver, 30); wait.untilLoad(); CompareTarget[] targets = { new CompareTarget(ScreenArea.of(SelectorType.TAG_NAME, "body")) }; assertionView.assertView("topPage", targets, HIDDEN_ELEMENTS); }
Example #17
Source File: SeleniumUtils.java From NetDiscovery with Apache License 2.0 | 5 votes |
/** * 重新调整窗口大小,以适应页面,需要耗费一定时间。建议等待合理的时间。 * @param driver */ public static void loadAll(WebDriver driver){ int width=driver.manage().window().getSize().width; //尝试性解决:https://github.com/ariya/phantomjs/issues/11526问题 driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); long height=(Long)((JavascriptExecutor)driver).executeScript("return document.body.scrollHeight;"); driver.manage().window().setSize(new Dimension(width, (int)height)); driver.navigate().refresh(); }
Example #18
Source File: HtmlExporterUtils.java From yuzhouwan with Apache License 2.0 | 5 votes |
/** * 初始化配置 PhantomJS Driver. * * @param url 目标 URL * @param addedCookie 添加 cookie * @return 初始化过的 PhantomJS Driver */ public static PhantomJSDriver prepare(String url, Cookie addedCookie, Integer width, Integer height) { // chrome driver maybe not necessary // download from https://sites.google.com/a/chromium.org/chromedriver/downloads // System.setProperty("webdriver.chrome.driver", // DirUtils.RESOURCES_PATH.concat( // PropUtils.getInstance().getProperty("html.exporter.webdriver.chrome.driver"))); DesiredCapabilities phantomCaps = DesiredCapabilities.chrome(); phantomCaps.setJavascriptEnabled(true); PropUtils p = PropUtils.getInstance(); phantomCaps.setCapability("phantomjs.page.settings.userAgent", p.getProperty("html.exporter.user.agent")); PhantomJSDriver driver = new PhantomJSDriver(phantomCaps); driver.manage().timeouts().implicitlyWait(Integer.parseInt( p.getProperty("html.exporter.driver.timeouts.implicitly.seconds")), TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(Integer.parseInt( p.getProperty("html.exporter.driver.timeouts.page.load.seconds")), TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(Integer.parseInt( p.getProperty("html.exporter.driver.timeouts.script.seconds")), TimeUnit.SECONDS); if (width == null || height == null) driver.manage().window().maximize(); else driver.manage().window().setSize(new Dimension(width, height)); if (addedCookie != null) driver.manage().addCookie(addedCookie); driver.get(url); // try { // // timeout is not work, so fix it by sleeping thread // Thread.sleep(Integer.valueOf(PropUtils.getInstance() // .getProperty("html.exporter.driver.timeouts.implicitly.seconds")) * 1000); // } catch (InterruptedException e) { // throw new RuntimeException(e); // } return driver; }
Example #19
Source File: Neodymium.java From neodymium-library with MIT License | 5 votes |
/** * Current page width and height * * @return {@link Dimension} object containing width and height of current page */ public static Dimension getPageSize() { Long width = Selenide.executeJavaScript("return document.documentElement.clientWidth"); Long height = Selenide.executeJavaScript("return document.documentElement.clientHeight"); return new Dimension(width.intValue(), height.intValue()); }
Example #20
Source File: TabViewPage.java From aws-device-farm-appium-tests-for-sample-app with Apache License 2.0 | 5 votes |
public void turnPageLeft() throws InterruptedException { acceptBadVideoAlert(); Dimension size = driver.manage().window().getSize(); int startX = (int) (size.width * START_OFFSET); int endX = (int) (size.width * END_OFFSET); int startY = size.height / 4; driver.swipe(startX, startY, endX, startY, SWIPE_DURATION); acceptBadVideoAlert(); }
Example #21
Source File: BaseTest.java From WebAndAppUITesting with GNU General Public License v3.0 | 5 votes |
/** * 参数初始化 */ protected void initParameters() { Dimension dimension; // 兼容循环执行时,如果sessionId为空,则重新启动 if (DriverFactory.getInstance().getDriver().getSessionId() == null) { DriverFactory.setDf(null); } dimension = DriverFactory.getInstance().getDriver().manage().window().getSize(); Constant.SCREEN_WIDTH = dimension.getWidth(); Constant.SCREEN_HEIGHT = dimension.getHeight(); LogUtil.info("界面宽高:" + Constant.SCREEN_WIDTH + "x" + Constant.SCREEN_HEIGHT); }
Example #22
Source File: ActionsLongPress.java From opentest with MIT License | 5 votes |
@Override public void run() { super.run(); By locator = this.readLocatorArgument("locator", null); Integer xOffset = this.readIntArgument("xOffset", 0); Integer yOffset = this.readIntArgument("yOffset", 0); Integer x = this.readIntArgument("x", null); Integer y = this.readIntArgument("y", null); if (locator != null) { MobileElement element = this.getElement(locator); Point position = element.getLocation(); Dimension dimension = element.getSize(); int xCoord = position.x + (dimension.width / 2) + xOffset; int yCoord = position.y + (dimension.height / 2) + yOffset; AppiumTestAction.getActionsInstance().longPress(PointOption.point( xCoord, yCoord)); } else if (x != null && y != null) { AppiumTestAction.getActionsInstance().longPress(PointOption.point(x, y)); } else { throw new RuntimeException( "You must either provide the locator argument of the element to press, " + "or the x and y arguments to indicate the exact coordinates to press at."); } }
Example #23
Source File: TwoFingerGesture.java From xframium-java with GNU General Public License v3.0 | 5 votes |
@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 startOne = getActualPoint( getStartOne(), screenDimension ); Point startTwo = getActualPoint( getStartTwo(), screenDimension ); Point endOne = getActualPoint( getEndOne(), screenDimension ); Point endTwo = getActualPoint( getEndTwo(), screenDimension ); MultiTouchAction tAction = new MultiTouchAction( appiumDriver ); TouchAction fingerOne = new TouchAction( appiumDriver ); fingerOne.press( PointOption.point( startOne.getX(), startOne.getY() ) ).moveTo( PointOption.point(endOne.getX(), endOne.getY() ) ).release(); TouchAction fingerTwo = new TouchAction( appiumDriver ); fingerTwo.press( PointOption.point( startTwo.getX(), startTwo.getY() ) ).moveTo( PointOption.point(endTwo.getX(), endTwo.getY() ) ).release(); tAction.add( fingerOne ).add( fingerTwo ).perform(); return true; }
Example #24
Source File: Gesture.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
@Action(object = ObjectType.ANY, desc = "Swipe down [<Data>]", input = InputType.OPTIONAL) public void swipeDown() { try { if (!browserAction()) { if (Element != null) { TouchAction action = new TouchAction(((MobileDriver) Driver)); int distance = 100; Point c = ((MobileElement) Element).getCenter(); LongPressOptions lop = new LongPressOptions(); lop.withElement(new ElementOption().withElement((MobileElement) Element)); lop.withPosition(new PointOption().withCoordinates(c.x, c.y + distance)); action.longPress(lop).waitAction(new WaitOptions().withDuration(Duration.ofMillis(500))).perform(); Report.updateTestLog(Action, "Sucessfully swiped towards down", Status.DONE); } else { throw new ElementException(ElementException.ExceptionType.Element_Not_Found, Condition); } } else { Dimension size = ((MobileDriver) Driver).manage().window().getSize(); int startY, endY; if (Data != null && Data.contains(",")) { startY = (int) (size.height * (getInt(Data, 0, 20) / 100d)); endY = (int) (size.height * (getInt(Data, 1, 80) / 100d)); } else { startY = (int) (size.height * 0.20); endY = (int) (size.height * 0.80); } int X = size.width / 2; swipe(X, startY, X, endY, Duration.ofMillis(getInt(Data, 2, defWaitTimeOut))); Report.updateTestLog(Action, "Sucessfully swiped towards down", Status.DONE); } } catch (Exception ex) { Report.updateTestLog(Action, ex.getMessage(), Status.FAIL); Logger.getLogger(Gesture.class.getName()).log(Level.SEVERE, null, ex); } }
Example #25
Source File: BrowserManager.java From BHBot with GNU General Public License v3.0 | 5 votes |
private Point getChromeOffset(int x, int y) { // As of Chrome 75, offsets are calculated from the center of the elements if (getChromeVersion() >= 75) { Dimension gameDimension = game.getSize(); int gameCenterX = gameDimension.width / 2; int gameCenterY = gameDimension.height / 2; return new Point(x -gameCenterX, y - gameCenterY); } else { return new Point(x, y); } }
Example #26
Source File: BaseIOSPickerWheelSteps.java From colibri-ui with Apache License 2.0 | 5 votes |
public void setPrevPickerWheelValue(WebElement pickerWheelElement, double step) { Point center = ((IOSElement) pickerWheelElement).getCenter(); Dimension size = pickerWheelElement.getSize(); int height = size.getHeight(); TouchAction touchAction = new TouchAction(driver); touchAction.press(point(center.getX(), center.getY() - (int) (height * step))).release(); touchAction.perform(); }
Example #27
Source File: BaseIOSPickerWheelSteps.java From colibri-ui with Apache License 2.0 | 5 votes |
@Step @When("установить пикер в последнее значение") public void setLastPickerWheelValue() { WebElement webElement = driver.findElement(By.xpath(pickerWheelXPath)); Point center = ((IOSElement) webElement).getCenter(); Dimension size = webElement.getSize(); int height = size.getHeight(); Point target = new Point(center.getX(), center.getY() + (int) (height * stepToLast)); TouchAction touchAction = new TouchAction(driver); touchAction.press(point(target.getX(), target.getY())).release(); touchAction.perform(); }
Example #28
Source File: WebUtility.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
/** * Resize window to given dimensions. * * @param width * @param height */ public void resizeWindow(final int width, final int height) { try { TestLogging.logWebStep("Resize browser window to width " + width + " height " + height, false); Dimension size = new Dimension(width, height); driver.manage().window().setPosition(new Point(0, 0)); driver.manage().window().setSize(size); } catch (Exception ex) { } }
Example #29
Source File: RoomClientBrowserTest.java From kurento-room with Apache License 2.0 | 5 votes |
@Override public void setupBrowserTest() throws InterruptedException { super.setupBrowserTest(); execExceptions.clear(); if (testScenario != null && testScenario.getBrowserMap() != null && testScenario.getBrowserMap().size() > 0) { int row = 0; int col = 0; for (final String browserKey : testScenario.getBrowserMap().keySet()) { Browser browser = getPage(browserKey).getBrowser(); browser.getWebDriver().manage().window() .setSize(new Dimension(WEB_TEST_BROWSER_WIDTH, WEB_TEST_BROWSER_HEIGHT)); browser .getWebDriver() .manage() .window() .setPosition( new Point(col * WEB_TEST_BROWSER_WIDTH + WEB_TEST_LEFT_BAR_WIDTH, row * WEB_TEST_BROWSER_HEIGHT + WEB_TEST_TOP_BAR_WIDTH)); col++; if (col * WEB_TEST_BROWSER_WIDTH + WEB_TEST_LEFT_BAR_WIDTH > WEB_TEST_MAX_WIDTH) { col = 0; row++; } } } }
Example #30
Source File: DraggableWebElement.java From bobcat with Apache License 2.0 | 5 votes |
private Point getCurrentLocation() { Point inViewPort = null; switcher.switchTo(getFramePath()); try { Dimension size = webElement.getSize(); inViewPort = ((Locatable) webElement).getCoordinates().inViewPort() .moveBy(size.getWidth() / 2, size.getHeight() / 2); } finally { switcher.switchBack(); } return inViewPort; }