How to get cookie information as JSON
Cookie cookie1 = driver.manage().getCookieNamed(“1P_JAR”); Map jsonObject = cookie1.toJson(); System.out.println(jsonObject.toString());
Cookie cookie1 = driver.manage().getCookieNamed(“1P_JAR”); Map jsonObject = cookie1.toJson(); System.out.println(jsonObject.toString());
Cookie cookie = driver.manage().getCookieNamed(“1P_JAR”); System.out.println(“Name : ” + cookie.getName()); System.out.println(“Value : ” + cookie.getValue()); System.out.println(“Domain : ” + cookie.getDomain()); System.out.println(“Path : ” + cookie.getPath()); System.out.println(“Expiry : ” + cookie.getExpiry()); System.out.println(“Secure …
Set cookies = driver.manage().getCookies(); for(Cookie cookie: cookies) { System.out.println(“Name : ” + cookie.getName()); System.out.println(“Value : ” + cookie.getValue()); System.out.println(“Domain : ” + cookie.getDomain()); System.out.println(“Path : ” + cookie.getPath()); System.out.println(“Expiry : …
How to take the screenshot from UIAutomator instead of chromedriver? This might be of use to you if you are interetsed to see whole picture of device. What you get …
public boolean Method_isCurrentOrientationPortrait(AppiumDriver driver) { String ort = driver.getOrientation().name(); ScreenOrientation orientation = ScreenOrientation.valueOf(ort); if (orientation == ScreenOrientation.PORTRAIT) { return true; } else { return false; } }
public boolean isCurrentOrientationLandScape(AppiumDriver driver) { String ort = driver.getOrientation().name(); ScreenOrientation orientation = ScreenOrientation.valueOf(ort); if (orientation == ScreenOrientation.LANDSCAPE) { return true; } else { return false; } }
public void pressAndroidMenu(AppiumDriver driver) { AndroidDriver androidDriver = (AndroidDriver) driver; androidDriver.pressKey(new KeyEvent(AndroidKey.MENU)); }
private void swipeOnSeekbar(AppiumDriver driver, WebElement element, int percentage) { Point point = element.getLocation(); Dimension eleSize = element.getSize(); int startX = point.getX(); int startY = point.getY() + (eleSize.getHeight() / 2); int …
public void longPressOnElement(AppiumDriver driver, WebElement elment) { new TouchActions(driver).longPress(elment).perform(); }
Code: caps.setCapability(“ignoreAboutBlankUrl”, true); Ignore webviews which are pointed to the about:blank url. These webviews will not appear in the context list and you cannot set the context to these webviews. …