List of usage examples for org.openqa.selenium WebElement getSize
Dimension getSize();
From source file:org.xframium.page.element.SeleniumElement.java
License:Open Source License
public boolean _release() { WebElement webElement = getElement(); if (webElement != null && webElement.getSize().getHeight() > 0 && webElement.getSize().getWidth() > 0) { if (webDriver instanceof HasInputDevices) { new Actions(webDriver).release(webElement).build().perform(); return true; }/* w w w. j a v a 2 s. com*/ } return false; }
From source file:org.xframium.page.element.SeleniumElement.java
License:Open Source License
@Override protected Dimension _getSize() { WebElement webElement = getElement(); return webElement.getSize(); }
From source file:renascere.Renascere.java
License:Open Source License
/** * @Description Method that manipulates a given object. *//* ww w . j av a 2 s . c o m*/ public static void manipulateObject(WebElement element, oAction oAction, String sData) { try { //Manipulate Object switch (oAction) { case CLEAR: element.clear(); break; case CLICK: element.click(); break; case TYPE: element.sendKeys(sData); break; case REPLACE: element.clear(); element.sendKeys(sData); break; case SELECT: Select dropDown = new Select(element); dropDown.selectByVisibleText(sData); break; case GETATT: Vars.g_sTemp = element.getAttribute(sData); break; case GETPOS: Vars.g_sTemp = element.getLocation().toString(); break; case GETSIZE: Vars.g_sTemp = element.getSize().toString(); break; case GETTEXT: Vars.g_sTemp = element.getText(); break; default: break; } //pauseExecution(Fctes.fTimeQSecond); } catch (Exception e) { frmError("manipulating an object with action (" + oAction + ").", e.getMessage(), severity.HIGH); } }
From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java
License:Apache License
@Test void canFireEventForWebElementGetSize() { Fixture fixture = new Fixture(); final WebElement mockedElement = mock(WebElement.class); final Dimension dimension = new Dimension(10, 20); when(fixture.mockedDriver.findElement(By.id("id"))).thenReturn(mockedElement); when(mockedElement.getSize()).thenReturn(dimension); assertSame(fixture.driver.findElement(By.id("id")).getSize(), dimension); verify(fixture.mockedDriver, times(1)).findElement(By.id("id")); verifyNoMoreInteractions(fixture.mockedDriver); verify(fixture.listener, times(1)).beforeFindElement(fixture.mockedDriver, By.id("id")); verify(fixture.listener, times(1)).afterFindElement(mockedElement, fixture.mockedDriver, By.id("id")); verify(mockedElement, times(1)).getSize(); verifyNoMoreInteractions(mockedElement); verify(fixture.listener, times(1)).beforeGetSize(mockedElement); verify(fixture.listener, times(1)).afterGetSize(dimension, mockedElement); verifyNoMoreInteractions(fixture.listener); }
From source file:TestSuite1.TestCase1.java
@Test public void test() throws InterruptedException { System.out.println("Test Start"); WebDriverWait wait = new WebDriverWait(driver, 10); int WindowsY = 752; int y;//w w w . j ava2s . co m int x1; int y1; int start; int starty; int end; int endy; final int maxcount = 20; int count = maxcount; WebElement element = null; start = driver.findElement(By.xpath( "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.view.View[1]/android.widget.ListView[1]/android.widget.LinearLayout[3]")) .getLocation().getY(); System.out.println(start); starty = driver.findElement(By.xpath( "//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.view.View[1]/android.widget.ListView[1]/android.widget.LinearLayout[3]")) .getSize().getHeight(); System.out.println(starty); end = driver.findElement( By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/main_header")) .getLocation().getY(); System.out.println(end); endy = driver.findElement( By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/main_header")) .getSize().getHeight(); System.out.println(endy); y = start + starty; x1 = WindowsY / 2; y1 = end + endy; while (count > 0) { try { Thread.sleep(1000); element = driver.findElement( By.className("android.widget.TextView").name("SK()?")); break; } catch (NoSuchElementException nsee) { System.out.println(" ? . scroll ."); } catch (InterruptedException e) { } try { Thread.sleep(1000); } catch (InterruptedException e) { } driver.swipe(x1, y, x1, y1, 6000); count--; } System.out.println("? " + element.getText()); Thread.sleep(5000); assertEquals(element.getText(), "SK()?"); // driver.findElement(By.className("android.widget.LinearLayout").id("com.skmc.okcashbag.home_google:id/summary")).click(); // element.click(); int ey = element.getLocation().getY(); int ex = element.getLocation().getX(); int eh = element.getSize().getHeight(); int ew = element.getSize().getWidth(); Thread.sleep(2000); // WebElement ee = // driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]")); WebElement ee = driver .findElement(By.className("android.view.View").id("com.skmc.okcashbag.home_google:id/empty_view")); int TestY = (ee.getLocation().getY() - ee.getSize().getHeight()); System.out.println(ee.getLocation().getY() - ee.getSize().getHeight()); System.out.println(ee.getLocation().getX()); System.out.println(ee.getSize().getHeight()); System.out.println(ee.getSize().getWidth()); System.out.println(" " + TestY); System.out.println(ey); System.out.println(ex); System.out.println(eh); System.out.println(ew); driver.tap(1, ex + (ew / 2), TestY + 10, 500); // driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.widget.DrawerLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]")).click(); /** * ? ? ? ? ?? ? / ? / ? ? ? * ture */ String[] Result = { "", "? ?? 264 The Planet", "1599-0512", "104-86-36968", "2014--0036", "?", "?", "? ?" }; WebElement Bizceo = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_ceo")); WebElement Addres = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_address")); WebElement Bizcall = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_call")); WebElement Bizlicense = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_license")); WebElement Bizsalereport = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_sale_report")); WebElement Bizuseagreement = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_use_agreement")); WebElement Bizprivacy = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy")); WebElement Bizinfom = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_infom")); assertEquals(Bizceo.getText(), Result[0].toString()); assertEquals(Addres.getText(), Result[1].toString()); assertEquals(Bizcall.getText(), Result[2].toString()); assertEquals(Bizlicense.getText(), Result[3].toString()); assertEquals(Bizsalereport.getText(), Result[4].toString()); assertEquals(Bizuseagreement.getText(), Result[5].toString()); assertEquals(Bizprivacy.getText(), Result[6].toString()); assertEquals(Bizinfom.getText(), Result[7].toString()); /** * ? ?? / ? / ? ? ? ?? ?? ? */ /** * ? ? */ Bizuseagreement.click(); WebElement Title = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/title_txt")); assertEquals(Title.getText(), "OK? ?"); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn"))); driver.findElement( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn")).click(); /* * ? ?? ? ? */ driver.tap(1, ex + (ew / 2), TestY + 10, 500); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy"))); driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_privacy")) .click(); // Bizprivacy.click(); Title = driver.findElement( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/title_txt")); assertEquals(Title.getText(), "? "); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn"))); driver.findElement( By.className("android.widget.ImageView").id("com.skmc.okcashbag.home_google:id/back_btn")).click(); /* * ? ?? ? ?(? ) ? ? */ driver.tap(1, ex + (ew / 2), TestY + 10, 500); wait.until(ExpectedConditions.elementToBeClickable( By.className("android.widget.TextView").id("com.skmc.okcashbag.home_google:id/biz_infom"))); Bizinfom.click(); WebElement url = driver .findElement(By.className("android.widget.EditText").id("com.android.chrome:id/url_bar")); System.out.println(url.getText()); Boolean UrlEquals = url.getText().contains("www.ftc.go.kr"); assertTrue(UrlEquals); driver.navigate().back(); /** *? ? ?? ? */ driver.findElement(By.className("android.widget.ImageView") .id("com.skmc.okcashbag.home_google:id/eventbanner_message")).click(); HashMap<String, String> scrollObject = new HashMap<String, String>(); RemoteWebElement element1 = (RemoteWebElement) ((AndroidDriver) driver) .findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.ListView\")"); JavascriptExecutor js = (JavascriptExecutor) driver; String webElementId = ((RemoteWebElement) element).getId(); scrollObject.put("text", "OK? ? 16.01.26~16.04.30 ??"); scrollObject.put("element", webElementId); js.executeScript("mobile: scrollTo", scrollObject); }
From source file:zz.pseas.ghost.utils.BrowserUtil.java
License:Apache License
public static byte[] captureScreenShotById(WebDriver driver, String id) throws IOException { byte[] bytes = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); WebElement ele = driver.findElement(By.id(id)); ByteArrayInputStream in = new ByteArrayInputStream(bytes); BufferedImage image = ImgUtil.bytesToBImage(bytes); ImageIO.write(image, "jpg", new File("d:/big.jpg")); in.close();//from w w w . j a va2 s . com System.out.println(image.getType()); Point p = ele.getLocation(); Dimension xy = ele.getSize(); BufferedImage subImage = image.getSubimage(p.getX(), p.getY(), xy.getWidth(), xy.getHeight()); ImageIO.write(subImage, "jpg", new File("d:/sc.jpg")); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(subImage, "jpg", out); out.flush(); byte[] res = out.toByteArray(); out.close(); return res; }