How to use getTimezone method of com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone.getTimezone

Source:AndroidService.java Github

copy

Full Screen

...901 autoTimeZone = "1";902 }903 executeAbdCommand("shell settings put global auto_time_zone " + autoTimeZone);904 setSystemTime(dt.getTimeFormat());905 if (!dt.getTimezone().isEmpty()) {906 executeAbdCommand("shell setprop persist.sys.timezone \"" + dt.getTimezone() + "\"");907 }908 if (dt.isRefreshDeviceTime()) {909 executeAbdCommand("shell am broadcast -a android.intent.action.TIME_SET");910 }911 if (dt.isChangeDateTime() && !dt.getSetDeviceDateTime().isEmpty()) {912 // Try to set date for device but it will not work on not rooted913 // devices914 executeAbdCommand("shell date " + dt.getSetDeviceDateTime());915 }916 String actualDT = executeAbdCommand("shell date -s %mynow%");917 LOGGER.info(actualDT);918 return actualDT;919 }920 /**921 * setDeviceTimeZoneBySetting922 *923 * @param timeZone String924 * @param settingsTZ String925 * @param timeFormat TimeFormat926 */927 private void setDeviceTimeZoneBySetting(String timeZone, String settingsTZ, TimeFormat timeFormat) {928 String actualTZ = getDeviceActualTimeZone();929 String tz = DeviceTimeZone.getTimezoneOffset(timeZone);930 if (isRequiredTimeZone(actualTZ, timeZone)) {931 LOGGER.info("Required timeZone is already set.");932 return;933 }934 try {935 openDateTimeSettingsSetupWizard(true, timeFormat);936 String res = getCurrentDeviceFocus();937 if (res.contains("settings.DateTimeSettingsSetupWizard")) {938 LOGGER.info("On settings.DateTimeSettingsSetupWizard page");939 } else {940 LOGGER.error("Not on settings.DateTimeSettingsSetupWizard page");941 }942 DateTimeSettingsPage dtSettingsPage = new DateTimeSettingsPage(getDriver());943 if (!dtSettingsPage.isOpened(3)) {944 openDateTimeSettingsSetupWizard(true, timeFormat);945 }946 if (dtSettingsPage.isOpened(3)) {947 LOGGER.info("Date Time Settings page was open.");948 } else {949 LOGGER.error("Date Time Settings page should be open.");950 }951 dtSettingsPage.openTimeZoneSetting();952 dtSettingsPage.selectTimeZone(tz, settingsTZ);953 dtSettingsPage.clickNextButton();954 } catch (Exception e) {955 LOGGER.error("Exception: ", e);956 }957 }958 /**959 * setDeviceTimeZoneByChangerApk960 *961 * @param timeZone String962 * @param timeFormat TimeFormat963 */964 private void setDeviceTimeZoneByChangerApk(String timeZone, TimeFormat timeFormat) {965 String actualTZ = getDeviceActualTimeZone();966 String tz = DeviceTimeZone.getTimezoneOffset(timeZone);967 LOGGER.info("Required TimeZone offset: " + tz);968 if (isRequiredTimeZone(actualTZ, timeZone)) {969 LOGGER.info("Required timeZone is already set.");970 return;971 }972 installApk(TZ_CHANGE_APP_PATH, true);973 try {974 forceTZChangingApkOpen(true, timeFormat);975 TZChangerPage tzChangerPage = new TZChangerPage(getDriver());976 if (tzChangerPage.isOpened(3)) {977 LOGGER.info("TimeZone changer main page was open.");978 } else {979 LOGGER.error("TimeZone changer main page should be open. Retry to open.");980 openTZChangingApk(true, timeFormat);...

Full Screen

Full Screen

Source:MobileUtils.java Github

copy

Full Screen

1/*******************************************************************************2 * Copyright 2013-2018 QaProSoft (http://www.qaprosoft.com).3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 *******************************************************************************/16package com.qaprosoft.carina.core.foundation.utils.mobile;17import java.time.Duration;18import org.apache.log4j.Logger;19import org.openqa.selenium.Dimension;20import org.openqa.selenium.Point;21import org.openqa.selenium.WebDriver;22import org.openqa.selenium.support.events.EventFiringWebDriver;23import org.testng.Assert;24import com.qaprosoft.carina.core.foundation.commons.SpecialKeywords;25import com.qaprosoft.carina.core.foundation.utils.Configuration;26import com.qaprosoft.carina.core.foundation.utils.Messager;27import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;28import com.qaprosoft.carina.core.foundation.utils.android.AndroidService;29import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;30import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;31import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;32import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;33import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;34import io.appium.java_client.MobileDriver;35import io.appium.java_client.TouchAction;36import io.appium.java_client.touch.LongPressOptions;37import io.appium.java_client.touch.WaitOptions;38import io.appium.java_client.touch.offset.ElementOption;39import io.appium.java_client.touch.offset.PointOption;40public class MobileUtils {41 protected static final Logger LOGGER = Logger.getLogger(MobileUtils.class);42 public enum Direction {43 LEFT,44 RIGHT,45 UP,46 DOWN,47 VERTICAL,48 HORIZONTAL,49 VERTICAL_DOWN_FIRST,50 HORIZONTAL_RIGHT_FIRST51 }52 protected static final long EXPLICIT_TIMEOUT = Configuration.getLong(Parameter.EXPLICIT_TIMEOUT);53 protected static final int MINIMUM_TIMEOUT = 2;54 private static final int DEFAULT_TOUCH_ACTION_DURATION = 1000;55 private static final int DEFAULT_MAX_SWIPE_COUNT = 50;56 private static final int DEFAULT_MIN_SWIPE_COUNT = 1;57 58 protected static DriverHelper helper = new DriverHelper();59 /**60 * Tap with TouchAction by the center of element61 *62 * @param element ExtendedWebElement63 */64 public static void tap(ExtendedWebElement element) {65 Point point = element.getLocation();66 Dimension size = helper.performIgnoreException(() -> element.getSize());67 68 tap(point.getX() + size.getWidth() / 2, point.getY() + size.getHeight() / 2);69 }70 /**71 * Tap with TouchAction by coordinates with default 1000ms duration72 *73 * @param startx int74 * @param starty int75 */76 public static void tap(int startx, int starty) {77 tap(startx, starty, DEFAULT_TOUCH_ACTION_DURATION);78 }79 /**80 * tap with TouchActions slowly to imitate log tap on element81 * 82 * @param elem ExtendedWebElement83 * element84 */85 public static void longTap(ExtendedWebElement elem) {86 Dimension size = helper.performIgnoreException(() -> elem.getSize());87 88 int width = size.getWidth();89 int height = size.getHeight();90 int x = elem.getLocation().getX() + width / 2;91 int y = elem.getLocation().getY() + height / 2;92 try {93 MobileUtils.swipe(x, y, x, y, 2500);94 } catch (Exception e) {95 LOGGER.error("Exception: " + e);96 }97 }98 /**99 * Tap and Hold (LongPress) on element100 *101 * @param element ExtendedWebElement102 * @return boolean103 */104 public static boolean longPress(ExtendedWebElement element) {105 //TODO: SZ migrate to FluentWaits106 try {107 WebDriver driver = getDriver();108 @SuppressWarnings("rawtypes")109 TouchAction<?> action = new TouchAction((MobileDriver<?>) driver);110 LongPressOptions options = LongPressOptions.longPressOptions().withElement(ElementOption.element(element.getElement()));111 action.longPress(options).release().perform();112 return true;113 } catch (Exception e) {114 LOGGER.info("Error occurs during longPress: " + e, e);115 }116 return false;117 }118 /**119 * Tap with TouchAction by coordinates with custom duration120 *121 * @param startx int122 * @param starty int123 * @param duration int124 */125 public static void tap(int startx, int starty, int duration) {126 //TODO: add Screenshot.capture()127 try {128 @SuppressWarnings("rawtypes")129 TouchAction<?> touchAction = new TouchAction((MobileDriver<?>) getDriver());130 PointOption<?> startPoint = PointOption.point(startx, starty);131 WaitOptions waitOptions = WaitOptions.waitOptions(Duration.ofMillis(duration));132 if (duration == 0) {133 // do not perform waiter as using 6.0.0. appium java client we do longpress instead of simple tap even with 0 wait duration134 touchAction.press(startPoint).release().perform();135 } else {136 touchAction.press(startPoint).waitAction(waitOptions).release().perform();137 }138 Messager.TAP_EXECUTED.info(String.valueOf(startx), String.valueOf(starty));139 } catch (Exception e) {140 Messager.TAP_NOT_EXECUTED.error(String.valueOf(startx), String.valueOf(starty));141 throw e;142 }143 }144 /**145 * swipe till element using TouchActions146 * 147 * @param element ExtendedWebElement148 * @return boolean149 */150 public static boolean swipe(final ExtendedWebElement element) {151 return swipe(element, null, Direction.UP, DEFAULT_MAX_SWIPE_COUNT, DEFAULT_TOUCH_ACTION_DURATION);152 }153 /**154 * swipe till element using TouchActions155 * 156 * @param element ExtendedWebElement157 * @param count int158 * @return boolean159 */160 public static boolean swipe(final ExtendedWebElement element, int count) {161 return swipe(element, null, Direction.UP, count, DEFAULT_TOUCH_ACTION_DURATION);162 }163 /**164 * swipe till element using TouchActions165 * 166 * @param element ExtendedWebElement167 * @param direction Direction168 * @return boolean169 */170 public static boolean swipe(final ExtendedWebElement element, Direction direction) {171 return swipe(element, null, direction, DEFAULT_MAX_SWIPE_COUNT, DEFAULT_TOUCH_ACTION_DURATION);172 }173 /**174 * swipe till element using TouchActions175 * 176 * @param element ExtendedWebElement177 * @param count int178 * @param duration int179 * @return boolean180 */181 public static boolean swipe(final ExtendedWebElement element, int count, int duration) {182 return swipe(element, null, Direction.UP, count, duration);183 }184 /**185 * swipe till element using TouchActions186 * 187 * @param element ExtendedWebElement188 * @param direction Direction189 * @param count int190 * @param duration int191 * @return boolean192 */193 public static boolean swipe(final ExtendedWebElement element, Direction direction, int count, int duration) {194 return swipe(element, null, direction, count, duration);195 }196 /**197 * Swipe inside container in default direction - Direction.UP198 * Number of attempts is limited by count argument199 * <p>200 *201 * @param element202 * ExtendedWebElement203 * @param container204 * ExtendedWebElement205 * @param count206 * int207 * @return boolean208 */209 public static boolean swipe(ExtendedWebElement element, ExtendedWebElement container, int count) {210 return swipe(element, container, Direction.UP, count, DEFAULT_TOUCH_ACTION_DURATION);211 }212 /**213 * Swipe inside container in default direction - Direction.UP214 * Number of attempts is limited by 5215 * <p>216 *217 * @param element218 * ExtendedWebElement219 * @param container220 * ExtendedWebElement221 * @return boolean222 */223 public static boolean swipe(ExtendedWebElement element, ExtendedWebElement container) {224 return swipe(element, container, Direction.UP, DEFAULT_MAX_SWIPE_COUNT, DEFAULT_TOUCH_ACTION_DURATION);225 }226 /**227 * Swipe inside container in specified direction228 * Number of attempts is limited by 5229 * <p>230 *231 * @param element232 * ExtendedWebElement233 * @param container234 * ExtendedWebElement235 * @param direction236 * Direction237 * @return boolean238 */239 public static boolean swipe(ExtendedWebElement element, ExtendedWebElement container, Direction direction) {240 return swipe(element, container, direction, DEFAULT_MAX_SWIPE_COUNT, DEFAULT_TOUCH_ACTION_DURATION);241 }242 /**243 * Swipe inside container in specified direction with default pulling timeout in 1000ms244 * Number of attempts is limited by count argument245 * <p>246 *247 * @param element248 * ExtendedWebElement249 * @param container250 * ExtendedWebElement251 * @param direction252 * Direction253 * @param count254 * int255 * @return boolean256 */257 public static boolean swipe(ExtendedWebElement element, ExtendedWebElement container, Direction direction,258 int count) {259 return swipe(element, container, direction, count, DEFAULT_TOUCH_ACTION_DURATION);260 }261 /**262 * Swipe to element inside container in specified direction while element263 * will not be present on the screen. If element is on the screen already,264 * scrolling will not be performed.265 * <p>266 *267 * @param element268 * element to which it will be scrolled269 * @param container270 * element, inside which scrolling is expected. null to scroll271 * @param direction272 * direction of scrolling. HORIZONTAL and VERTICAL support swiping in both directions automatically273 * @param count274 * for how long to scroll, ms275 * @param duration276 * pulling timeout, ms277 * @return boolean278 */279 public static boolean swipe(ExtendedWebElement element, ExtendedWebElement container, Direction direction,280 int count, int duration) {281 boolean isVisible = element.isVisible(1);282 if (isVisible) {283 // no sense to continue;284 LOGGER.info("element already present before swipe: " + element.getNameWithLocator().toString());285 return true;286 } else {287 LOGGER.info("swiping to element: " + element.getNameWithLocator().toString());288 }289 Direction oppositeDirection = Direction.DOWN;290 boolean bothDirections = false;291 switch (direction) {292 case UP:293 oppositeDirection = Direction.DOWN;294 break;295 case DOWN:296 oppositeDirection = Direction.UP;297 break;298 case LEFT:299 oppositeDirection = Direction.RIGHT;300 break;301 case RIGHT:302 oppositeDirection = Direction.LEFT;303 break;304 case HORIZONTAL:305 direction = Direction.LEFT;306 oppositeDirection = Direction.RIGHT;307 bothDirections = true;308 break;309 case HORIZONTAL_RIGHT_FIRST:310 direction = Direction.RIGHT;311 oppositeDirection = Direction.LEFT;312 bothDirections = true;313 break;314 case VERTICAL:315 direction = Direction.UP;316 oppositeDirection = Direction.DOWN;317 bothDirections = true;318 break;319 case VERTICAL_DOWN_FIRST:320 direction = Direction.DOWN;321 oppositeDirection = Direction.UP;322 bothDirections = true;323 break;324 default:325 throw new RuntimeException("Unsupported direction for swipeInContainerTillElement: " + direction);326 }327 int currentCount = count;328 while (!isVisible && currentCount-- > 0) {329 LOGGER.debug("Element not present! Swipe " + direction + " will be executed to element: " + element.getNameWithLocator().toString());330 swipeInContainer(container, direction, duration);331 LOGGER.info("Swipe was executed. Attempts remain: " + currentCount);332 isVisible = element.isVisible(1);333 }334 currentCount = count;335 while (bothDirections && !isVisible && currentCount-- > 0) {336 LOGGER.debug(337 "Element not present! Swipe " + oppositeDirection + " will be executed to element: " + element.getNameWithLocator().toString());338 swipeInContainer(container, oppositeDirection, duration);339 LOGGER.info("Swipe was executed. Attempts remain: " + currentCount);340 isVisible = element.isVisible(1);341 }342 LOGGER.info("Result: " + isVisible);343 return isVisible;344 }345 /**346 * Swipe by coordinates using TouchAction (platform independent)347 *348 * @param startx int349 * @param starty int350 * @param endx int351 * @param endy int352 * @param duration int Millis353 */354 @SuppressWarnings("rawtypes")355 public static void swipe(int startx, int starty, int endx, int endy, int duration) {356 LOGGER.debug("Starting swipe...");357 WebDriver drv = getDriver();358 LOGGER.debug("Getting driver dimension size...");359 Dimension scrSize = helper.performIgnoreException(() -> drv.manage().window().getSize());360 LOGGER.debug("Finished driver dimension size...");361 // explicitly limit range of coordinates362 if (endx >= scrSize.width) {363 LOGGER.warn("endx coordinate is bigger then device width! It will be limited!");364 endx = scrSize.width - 1;365 } else {366 endx = Math.max(1, endx);367 }368 if (endy >= scrSize.height) {369 LOGGER.warn("endy coordinate is bigger then device height! It will be limited!");370 endy = scrSize.height - 1;371 } else {372 endy = Math.max(1, endy);373 }374 LOGGER.debug("startx: " + startx + "; starty: " + starty + "; endx: " + endx + "; endy: " + endy375 + "; duration: " + duration);376 PointOption<?> startPoint = PointOption.point(startx, starty);377 PointOption<?> endPoint = PointOption.point(endx, endy);378 WaitOptions waitOptions = WaitOptions.waitOptions(Duration.ofMillis(duration));379 380 new TouchAction((MobileDriver<?>) drv).press(startPoint).waitAction(waitOptions).moveTo(endPoint).release()381 .perform();382 LOGGER.debug("Finished swipe...");383 }384 /**385 * swipeInContainer386 *387 * @param container ExtendedWebElement388 * @param direction Direction389 * @param duration int390 * @return boolean391 */392 public static boolean swipeInContainer(ExtendedWebElement container, Direction direction, int duration) {393 return swipeInContainer(container, direction, DEFAULT_MIN_SWIPE_COUNT, duration);394 }395 /**396 * swipeInContainer397 * 398 * @param container ExtendedWebElement399 * @param direction Direction400 * @param count int401 * @param duration int402 * @return boolean403 */404 public static boolean swipeInContainer(ExtendedWebElement container, Direction direction, int count, int duration) {405 int startx = 0;406 int starty = 0;407 int endx = 0;408 int endy = 0;409 Point elementLocation = null;410 Dimension elementDimensions = null;411 412 if (container == null) {413 // whole screen/driver is a container!414 WebDriver driver = getDriver();415 elementLocation = new Point(0, 0); // initial left corner for that case416 elementDimensions = helper.performIgnoreException(() -> driver.manage().window().getSize());417 } else {418 if (container.isElementNotPresent(5)) {419 Assert.fail("Cannot swipe! Impossible to find element " + container.getName());420 }421 elementLocation = container.getLocation();422 elementDimensions = helper.performIgnoreException(() -> container.getSize());423 }424 double minCoefficient = 0.3;425 double maxCoefficient = 0.6;426 // calculate default coefficient based on OS type427 String os = DevicePool.getDevice().getOs();428 if (os.equalsIgnoreCase(SpecialKeywords.ANDROID)) {429 minCoefficient = 0.25;430 maxCoefficient = 0.5;431 } else if (os.equalsIgnoreCase(SpecialKeywords.IOS) || os.equalsIgnoreCase(SpecialKeywords.MAC)) {432 minCoefficient = 0.25;433 maxCoefficient = 0.8;434 }435 switch (direction) {436 case LEFT:437 starty = endy = elementLocation.getY() + Math.round(elementDimensions.getHeight() / 2);438 startx = (int) (elementLocation.getX() + Math.round(maxCoefficient * elementDimensions.getWidth()));439 endx = (int) (elementLocation.getX() + Math.round(minCoefficient * elementDimensions.getWidth()));440 break;441 case RIGHT:442 starty = endy = elementLocation.getY() + Math.round(elementDimensions.getHeight() / 2);443 startx = (int) (elementLocation.getX() + Math.round(minCoefficient * elementDimensions.getWidth()));444 endx = (int) (elementLocation.getX() + Math.round(maxCoefficient * elementDimensions.getWidth()));445 break;446 case UP:447 startx = endx = elementLocation.getX() + Math.round(elementDimensions.getWidth() / 2);448 starty = (int) (elementLocation.getY() + Math.round(maxCoefficient * elementDimensions.getHeight()));449 endy = (int) (elementLocation.getY() + Math.round(minCoefficient * elementDimensions.getHeight()));450 break;451 case DOWN:452 startx = endx = elementLocation.getX() + Math.round(elementDimensions.getWidth() / 2);453 starty = (int) (elementLocation.getY() + Math.round(minCoefficient * elementDimensions.getHeight()));454 endy = (int) (elementLocation.getY() + Math.round(maxCoefficient * elementDimensions.getHeight()));455 break;456 default:457 throw new RuntimeException("Unsupported direction: " + direction);458 }459 LOGGER.debug(String.format("Swipe from (X = %d; Y = %d) to (X = %d; Y = %d)", startx, starty, endx, endy));460 try {461 for (int i = 0; i < count; ++i) {462 swipe(startx, starty, endx, endy, duration);463 }464 return true;465 } catch (Exception e) {466 LOGGER.error(String.format("Error during Swipe from (X = %d; Y = %d) to (X = %d; Y = %d): %s", startx, starty, endx, endy, e));467 }468 return false;469 }470 /**471 * Swipe up several times472 * 473 * @param times int474 * @param duration int475 */476 public static void swipeUp(final int times, final int duration) {477 for (int i = 0; i < times; i++) {478 swipeUp(duration);479 }480 }481 /**482 * Swipe up483 * 484 * @param duration int485 */486 public static void swipeUp(final int duration) {487 LOGGER.info("Swipe up will be executed.");488 swipeInContainer(null, Direction.UP, duration);489 }490 /**491 * Swipe down several times492 * 493 * @param times int494 * @param duration int495 */496 public static void swipeDown(final int times, final int duration) {497 for (int i = 0; i < times; i++) {498 swipeDown(duration);499 }500 }501 /**502 * Swipe down503 * 504 * @param duration int505 */506 public static void swipeDown(final int duration) {507 LOGGER.info("Swipe down will be executed.");508 swipeInContainer(null, Direction.DOWN, duration);509 }510 /**511 * Swipe left several times512 * 513 * @param times int514 * @param duration int515 */516 public static void swipeLeft(final int times, final int duration) {517 for (int i = 0; i < times; i++) {518 swipeLeft(duration);519 }520 }521 /**522 * Swipe left523 * 524 * @param duration int525 */526 public static void swipeLeft(final int duration) {527 LOGGER.info("Swipe left will be executed.");528 swipeLeft(null, duration);529 }530 /**531 * Swipe left in container532 * 533 * @param container534 * ExtendedWebElement535 * @param duration536 * int537 */538 public static void swipeLeft(ExtendedWebElement container, final int duration) {539 LOGGER.info("Swipe left will be executed.");540 swipeInContainer(container, Direction.LEFT, duration);541 }542 /**543 * Swipe right several times544 * 545 * @param times int546 * @param duration int547 */548 public static void swipeRight(final int times, final int duration) {549 for (int i = 0; i < times; i++) {550 swipeRight(duration);551 }552 }553 /**554 * Swipe right555 * 556 * @param duration int557 */558 public static void swipeRight(final int duration) {559 LOGGER.info("Swipe right will be executed.");560 swipeRight(null, duration);561 }562 /**563 * Swipe right in container564 * 565 * @param container566 * ExtendedWebElement567 * @param duration568 * int569 */570 public static void swipeRight(ExtendedWebElement container, final int duration) {571 LOGGER.info("Swipe right will be executed.");572 swipeInContainer(container, Direction.RIGHT, duration);573 }574 /**575 * Set Android Device Default TimeZone And Language based on config or to GMT and En576 * Without restoring actual focused apk.577 */578 public static void setDeviceDefaultTimeZoneAndLanguage() {579 setDeviceDefaultTimeZoneAndLanguage(false);580 }581 /**582 * set Android Device Default TimeZone And Language based on config or to GMT and En583 * 584 * @param returnAppFocus - if true store actual Focused apk and activity, than restore after setting Timezone and Language.585 */586 public static void setDeviceDefaultTimeZoneAndLanguage(boolean returnAppFocus) {587 try {588 String baseApp = "";589 String os = DevicePool.getDevice().getOs();590 if (os.equalsIgnoreCase(SpecialKeywords.ANDROID)) {591 AndroidService androidService = AndroidService.getInstance();592 if (returnAppFocus) {593 baseApp = androidService.getCurrentFocusedApkDetails();594 }595 String deviceTimezone = Configuration.get(Parameter.DEFAULT_DEVICE_TIMEZONE);596 String deviceTimeFormat = Configuration.get(Parameter.DEFAULT_DEVICE_TIME_FORMAT);597 String deviceLanguage = Configuration.get(Parameter.DEFAULT_DEVICE_LANGUAGE);598 DeviceTimeZone.TimeFormat timeFormat = DeviceTimeZone.TimeFormat.parse(deviceTimeFormat);599 DeviceTimeZone.TimeZoneFormat timeZone = DeviceTimeZone.TimeZoneFormat.parse(deviceTimezone);600 LOGGER.info("Set device timezone to " + timeZone.toString());601 LOGGER.info("Set device time format to " + timeFormat.toString());602 LOGGER.info("Set device language to " + deviceLanguage);603 boolean timeZoneChanged = androidService.setDeviceTimeZone(timeZone.getTimeZone(), timeZone.getSettingsTZ(), timeFormat);604 boolean languageChanged = androidService.setDeviceLanguage(deviceLanguage);605 LOGGER.info(String.format("Device TimeZone was changed to timeZone '%s' : %s. Device Language was changed to language '%s': %s",606 deviceTimezone,607 timeZoneChanged, deviceLanguage, languageChanged));608 if (returnAppFocus) {609 androidService.openApp(baseApp);610 }611 } else {612 LOGGER.info(String.format("Current OS is %s. But we can set default TimeZone and Language only for Android.", os));613 }614 } catch (Exception e) {615 LOGGER.error(e);616 }617 }618 /**619 * Hide keyboard if needed620 */621 public static void hideKeyboard() {622 try {623 ((MobileDriver<?>) getDriver()).hideKeyboard();624 } catch (Exception e) {625 if (!e.getMessage().contains("Soft keyboard not present, cannot hide keyboard")) {626 LOGGER.error("Exception appears during hideKeyboard: " + e);627 }628 }629 }630 public static WebDriver getDriver() {631 WebDriver drv = DriverPool.getDriver();632 if (drv instanceof EventFiringWebDriver) {633 return ((EventFiringWebDriver) drv).getWrappedDriver();634 } else {635 return drv;636 }637 }638}...

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2import java.util.TimeZone;3public class 1 {4public static void main(String[] args) {5DeviceTimeZone deviceTimeZone = new DeviceTimeZone();6TimeZone timeZone = deviceTimeZone.getTimeZone();7System.out.println(timeZone.getID());8}9}10import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;11import java.util.TimeZone;12public class 2 {13public static void main(String[] args) {14DeviceTimeZone deviceTimeZone = new DeviceTimeZone();15TimeZone timeZone = deviceTimeZone.getTimeZone();16System.out.println(timeZone.getID());17}18}19import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;20import java.util.TimeZone;21public class 3 {22public static void main(String[] args) {23DeviceTimeZone deviceTimeZone = new DeviceTimeZone();24TimeZone timeZone = deviceTimeZone.getTimeZone();25System.out.println(timeZone.getID());26}27}28import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;29import java.util.TimeZone;30public class 4 {31public static void main(String[] args) {32DeviceTimeZone deviceTimeZone = new DeviceTimeZone();33TimeZone timeZone = deviceTimeZone.getTimeZone();34System.out.println(timeZone.getID());35}36}37import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;38import java.util.TimeZone;39public class 5 {40public static void main(String[] args) {41DeviceTimeZone deviceTimeZone = new DeviceTimeZone();42TimeZone timeZone = deviceTimeZone.getTimeZone();43System.out.println(timeZone.getID());44}45}46import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;47import java.util.TimeZone;48public class 6 {49public static void main(String[] args) {50DeviceTimeZone deviceTimeZone = new DeviceTimeZone();51TimeZone timeZone = deviceTimeZone.getTimeZone();

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2import java.util.TimeZone;3public class 1 {4 public static void main(String[] args) {5 DeviceTimeZone deviceTimeZone = new DeviceTimeZone();6 TimeZone timeZone = deviceTimeZone.getTimezone();7 System.out.println("TimeZone: " + timeZone);8 }9}10import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;11import java.util.TimeZone;12public class 2 {13 public static void main(String[] args) {14 DeviceTimeZone deviceTimeZone = new DeviceTimeZone();15 TimeZone timeZone = deviceTimeZone.getTimezone();16 System.out.println("TimeZone: " + timeZone);17 }18}19import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;20import java.util.TimeZone;21public class 3 {22 public static void main(String[] args) {23 DeviceTimeZone deviceTimeZone = new DeviceTimeZone();24 TimeZone timeZone = deviceTimeZone.getTimezone();25 System.out.println("TimeZone: " + timeZone);26 }27}28import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;29import java.util.TimeZone;30public class 4 {31 public static void main(String[] args) {32 DeviceTimeZone deviceTimeZone = new DeviceTimeZone();33 TimeZone timeZone = deviceTimeZone.getTimezone();34 System.out.println("TimeZone: " + timeZone);35 }36}37import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;38import java.util.TimeZone;39public class 5 {40 public static void main(String[] args) {41 DeviceTimeZone deviceTimeZone = new DeviceTimeZone();42 TimeZone timeZone = deviceTimeZone.getTimezone();43 System.out.println("TimeZone: " + timeZone);44 }45}46import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2String timezone = DeviceTimeZone.getTimezone();3import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;4String datetime = DeviceTimeZone.getDateTime();5import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;6String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss");7import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;8String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC");9import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;10String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC", Locale.US);11import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;12String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC", Locale.US, TimeZone.getTimeZone("UTC"));13import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;14String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC", Locale.US, TimeZone.getTimeZone("UTC"), "yyyy-MM-dd HH:mm:ss");15import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;16String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC", Locale.US, TimeZone.getTimeZone("UTC"), "yyyy-MM-dd HH:mm:ss", "UTC");17import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;18String datetime = DeviceTimeZone.getDateTime("yyyy-MM-dd HH:mm:ss", "UTC", Locale.US, TimeZone.getTimeZone("UTC

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2public class 1 {3public static void main(String[] args) {4String timezone = DeviceTimeZone.getTimezone();5System.out.println(timezone);6}7}8import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;9public class 2 {10public static void main(String[] args) {11String timezone = DeviceTimeZone.getTimezone();12System.out.println(timezone);13}14}15import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;16public class 3 {17public static void main(String[] args) {18String timezone = DeviceTimeZone.getTimezone();19System.out.println(timezone);20}21}22import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;23public class 4 {24public static void main(String[] args) {25String timezone = DeviceTimeZone.getTimezone();26System.out.println(timezone);27}28}29import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;30public class 5 {31public static void main(String[] args) {32String timezone = DeviceTimeZone.getTimezone();33System.out.println(timezone);34}35}36import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;37public class 6 {38public static void main(String[] args) {39String timezone = DeviceTimeZone.getTimezone();40System.out.println(timezone);41}42}43import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;44public class 7 {45public static void main(String[] args) {46String timezone = DeviceTimeZone.getTimezone();47System.out.println(timezone);48}49}

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2import java.util.TimeZone;3public class getTimezone{4public static void main(String[] args){5DeviceTimeZone dtz = new DeviceTimeZone();6TimeZone tz = dtz.getTimeZone();7System.out.println(tz);8}9}10Syntax: public int getOffset(long date)11import java.util.TimeZone;12public class getOffset{13public static void main(String[] args){14TimeZone tz = TimeZone.getTimeZone("Asia/Kolkata");15int offset = tz.getOffset(0);16System.out.println(offset);17}18}19Syntax: public String getID()20import java.util.TimeZone;21public class getID{22public static void main(String[] args){23TimeZone tz = TimeZone.getTimeZone("Asia/Kolkata");24String id = tz.getID();25System.out.println(id);26}27}28Syntax: public String getDisplayName()29import java.util.TimeZone;30public class getDisplayName{31public static void main(String[] args){32TimeZone tz = TimeZone.getTimeZone("Asia/Kolkata");33String name = tz.getDisplayName();34System.out.println(name);35}36}

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;2import java.util.TimeZone;3import java.util.Date;4public class 1 {5 public static void main(String[] args) {6 String timeZone = DeviceTimeZone.getTimezone();7 System.out.println("TimeZone: " + timeZone);8 }9}10import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;11import java.util.TimeZone;12import java.util.Date;13public class 2 {14 public static void main(String[] args) {15 TimeZone timeZone = DeviceTimeZone.getDeviceTimeZone();16 System.out.println("TimeZone: " + timeZone.getDisplayName());17 }18}19import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;20import java.util.TimeZone;21import java.util.Date;22public class 3 {23 public static void main(String[] args) {24 TimeZone timeZone = DeviceTimeZone.getDeviceTimeZone();25 System.out.println("TimeZone: " + timeZone.getDisplayName());26 }27}28import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;29import java.util.TimeZone;30import java.util.Date;31public class 4 {32 public static void main(String[] args) {33 String timeZone = DeviceTimeZone.getTimezone();34 System.out.println("TimeZone: " + timeZone);35 }36}37import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;38import java.util.TimeZone;39import java.util.Date;40public class 5 {41 public static void main(String[] args) {42 String timeZone = DeviceTimeZone.getTimezone();43 System.out.println("TimeZone: " + timeZone);44 }45}46import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;47import java.util.TimeZone;48import java.util.Date;49public class 6 {

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1public class 1 {2 public static void main(String[] args) {3 try {4 String result = DeviceTimeZone.getTimezone();5 System.out.println(result);6 } catch (Exception e) {7 System.err.println(e);8 }9 }10}

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.utils.android;2import java.io.BufferedReader;3import java.io.IOException;4import java.io.InputStreamReader;5import java.util.ArrayList;6import java.util.List;7import org.apache.log4j.Logger;8import com.qaprosoft.carina.core.foundation.utils.Configuration;9import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone.Timezone;10public class DeviceTimeZone {11 private static final Logger LOGGER = Logger.getLogger(DeviceTimeZone.class);12 private DeviceTimeZone() {13 }14 public enum Timezone {15 GMT_12("GMT-12", "International Date Line West"),16 GMT_11("GMT-11", "Midway Island, Samoa"),17 GMT_10("GMT-10", "Hawaii"),18 GMT_9("GMT-9", "Alaska"),19 GMT_8("GMT-8", "Pacific Time (US & Canada)"),20 GMT_7("GMT-7", "Mountain Time (US & Canada)"),21 GMT_6("GMT-6", "Central Time (US & Canada), Mexico City"),22 GMT_5("GMT-5", "Eastern Time (US & Canada), Bogota, Lima"),23 GMT_4("GMT-4", "Atlantic Time (Canada), Caracas, La Paz"),24 GMT_3("GMT-3", "Greenland, Brasilia, Buenos Aires"),25 GMT_2("GMT-2", "Mid-Atlantic"),26 GMT_1("GMT-1", "Azores, Cape Verde Islands"),27 GMT("GMT", "Western Europe Time, London, Lisbon, Casablanca"),28 GMT1("GMT+1", "Brussels, Copenhagen, Madrid, Paris"),29 GMT2("GMT+2", "Kaliningrad, South Africa"),30 GMT3("GMT+3", "Baghdad, Riyadh, Moscow, St. Petersburg"),31 GMT4("GMT+4", "Abu Dhabi

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1public class getTimezone {2public static void main(String[] args) throws Exception {3DeviceTimeZone deviceTimeZone = new DeviceTimeZone();4deviceTimeZone.getTimezone();5}6}7public class getDeviceTimeZone {8public static void main(String[] args) throws Exception {9DeviceTimeZone deviceTimeZone = new DeviceTimeZone();10deviceTimeZone.getDeviceTimeZone();11}12}13public class getDeviceTimeZone {14public static void main(String[] args) throws Exception {15DeviceTimeZone deviceTimeZone = new DeviceTimeZone();16deviceTimeZone.getDeviceTimeZone();17}18}19public class getTimezone {20public static void main(String[] args) throws Exception {21DeviceTimeZone deviceTimeZone = new DeviceTimeZone();22deviceTimeZone.getTimezone();23}24}25public class getDeviceTimeZone {26public static void main(String[] args) throws Exception {27DeviceTimeZone deviceTimeZone = new DeviceTimeZone();28deviceTimeZone.getDeviceTimeZone();29}30}31public class getTimezone {32public static void main(String[] args) throws Exception {33DeviceTimeZone deviceTimeZone = new DeviceTimeZone();34deviceTimeZone.getTimezone();35}36}37public class getTimezone {38public static void main(String[] args) throws Exception {39DeviceTimeZone deviceTimeZone = new DeviceTimeZone();40deviceTimeZone.getTimezone();41}42}43public class getDeviceTimeZone {44public static void main(String[] args) throws Exception {45DeviceTimeZone deviceTimeZone = new DeviceTimeZone();46deviceTimeZone.getDeviceTimeZone();47}48}

Full Screen

Full Screen

getTimezone

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.android;2import java.util.ArrayList;3import java.util.List;4import java.util.TimeZone;5import java.util.concurrent.TimeUnit;6import org.openqa.selenium.By;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.openqa.selenium.support.ui.ExpectedConditions;11import org.openqa.selenium.support.ui.WebDriverWait;12import org.testng.Assert;13import org.testng.annotations.AfterMethod;14import org.testng.annotations.BeforeMethod;15import org.testng.annotations.Test;16import com.qaprosoft.carina.core.foundation.utils.android.DeviceTimeZone;17import com.qaprosoft.carina.core.foundation.webdriver.DriverHelper;18import com.qaprosoft.carina.core.foundation.webdriver.DriverPool;19import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;20import com.qaprosoft.carina.core.foundation.webdriver.device.Device;21import com.qaprosoft.carina.core.foundation.webdriver.device.DevicePool;22import com.qaprosoft.carina.core.foundation.webdriver.locator.ExtendedFindBy;23import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumCommandExecutor;24import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumDriver;25import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumEventListener;26import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumExceptionListener;27import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumScrollEventListener;28import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumTouchEventListener;29import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumVideoListener;30import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebCommandExecutor;31import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebEventListener;32import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebExceptionListener;33import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebScrollEventListener;34import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebTouchEventListener;35import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringAppiumWebVideoListener;36import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringWebDriverEventListener;37import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringWebDriverExceptionListener;38import com.qapro

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful