Best Carina code snippet using com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.Notification.equals
Source:AndroidService.java
...486 text = nativeNotificationPage.getItemText(i);487 LOGGER.info("Notification title is: " + title);488 LOGGER.info("Notification text is: " + text);489 if (!expectedTitle.isEmpty()) {490 if (title.equals(expectedTitle)) {491 notificationItemNum = i;492 LOGGER.info("Found expected title '" + expectedTitle + "' in notification #" + notificationItemNum);493 return true;494 } else if (partially) {495 if (expectedTitle.contains(title)) {496 notificationItemNum = i;497 LOGGER.info(498 "Found that expected title '" + expectedTitle + "' contains '" + title + "' in notification #" + notificationItemNum);499 return true;500 }501 }502 }503 if (!expectedText.isEmpty()) {504 if (text.equals(expectedText)) {505 notificationItemNum = i;506 LOGGER.info("Found expected text '" + expectedText + "' in notification #" + notificationItemNum);507 return true;508 } else if (partially) {509 if (expectedText.contains(text)) {510 notificationItemNum = i;511 LOGGER.info(512 "Found that expected text '" + expectedText + "' contains '" + text + "' in notification #" + notificationItemNum);513 return true;514 }515 }516 }517 }518 return false;519 }520 /**521 * clearNotifications522 */523 public void clearNotifications() {524 LOGGER.info("Clear notifications");525 NotificationPage notificationPage = new NotificationPage(getDriver());526 int attempts = 3;527 boolean isStatusBarOpened;528 // three attempts will be executed to clear notifications529 for (int i = 0; i < attempts; i++) {530 collapseStatusBar();531 expandStatusBar();532 // wait until status bar will be opened533 isStatusBarOpened = notificationPage.isOpened(INIT_TIMEOUT);534 if (!isStatusBarOpened) {535 LOGGER.info(String.format("Status bar isn't opened after %d seconds. One more attempt.", (int) INIT_TIMEOUT));536 expandStatusBar();537 }538 LOGGER.debug("Page source [expand status bar]: ".concat(getDriver().getPageSource()));539 Screenshot.capture(getDriver(), "Clear notification - screenshot. Status bar should be opened. Attempt: " + i);540 try {541 notificationPage.clearNotifications();542 } catch (Exception e) {543 LOGGER.info("Exception during notification extraction.");544 }545 }546 collapseStatusBar();547 }548 /**549 * isStatusBarExpanded550 *551 * @return boolean552 */553 public boolean isStatusBarExpanded() {554 NotificationPage notificationPage = new NotificationPage(getDriver());555 return notificationPage.isStatusBarExpanded();556 }557 // End of Notification section558 // Change Device Language section559 /**560 * change Android Device Language with default parameters561 *562 * @param language String563 * @return boolean564 */565 public boolean setDeviceLanguage(String language) {566 return setDeviceLanguage(language, true, 20);567 }568 /**569 * change Android Device Language570 * <p>571 * Url: <a href=572 * "http://play.google.com/store/apps/details?id=net.sanapeli.adbchangelanguage&hl=ru&rdid=net.sanapeli.adbchangelanguage">573 * ADBChangeLanguage apk </a> Change locale (language) of your device via574 * ADB (on Android OS version 6.0, 5.0, 4.4, 4.3, 4.2 and older). No need to575 * root your device! With ADB (Android Debug Bridge) on your computer, you576 * can fast switch the device locale to see how your application UI looks on577 * different languages. Usage: - install this app - setup adb connection to578 * your device (http://developer.android.com/tools/help/adb.html) - Android579 * OS 4.2 onwards (tip: you can copy the command here and paste it to your580 * command console): adb shell pm grant net.sanapeli.adbchangelanguage581 * android.permission.CHANGE_CONFIGURATION582 * <p>583 * English: adb shell am start -n584 * net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language en Russian:585 * adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage586 * -e language ru Spanish: adb shell am start -n587 * net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language es588 *589 * @param language to set. Can be es, en, etc.590 * @param changeConfig boolean if true - update config locale and language591 * params592 * @param waitTime int wait in seconds before device refresh.593 * @return boolean594 */595 public boolean setDeviceLanguage(String language, boolean changeConfig, int waitTime) {596 boolean status = false;597 String initLanguage = language;598 String currentAndroidVersion = DevicePool.getDevice().getOsVersion();599 LOGGER.info("Do not concat language for Android. Keep: " + language);600 language = language.replace("_", "-");601 LOGGER.info("Refactor language to : " + language);602 String actualDeviceLanguage = getDeviceLanguage();603 if (language.contains(actualDeviceLanguage.toLowerCase()) || actualDeviceLanguage.toLowerCase().contains(language)) {604 LOGGER.info("Device already have expected language: " + actualDeviceLanguage);605 return true;606 }607 String setLocalizationChangePermissionCmd = "shell pm grant net.sanapeli.adbchangelanguage android.permission.CHANGE_CONFIGURATION";608 String setLocalizationCmd = "shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language " + language;609 LOGGER.info("Try set localization change permission with following cmd:" + setLocalizationChangePermissionCmd);610 String expandOutput = executeAdbCommand(setLocalizationChangePermissionCmd);611 if (expandOutput.contains("Unknown package: net.sanapeli.adbchangelanguage")) {612 LOGGER.info("Looks like 'ADB Change Language apk' is not installed. Install it and try again.");613 installApk(LANGUAGE_CHANGE_APP_PATH, true);614 expandOutput = executeAdbCommand(setLocalizationChangePermissionCmd);615 }616 LOGGER.info("Output after set localization change permission using 'ADB Change Language apk': " + expandOutput);617 LOGGER.info("Try set localization to '" + language + "' with following cmd: " + setLocalizationCmd);618 String changeLocaleOutput = executeAdbCommand(setLocalizationCmd);619 LOGGER.info("Output after set localization to '" + language + "' using 'ADB Change Language apk' : " + changeLocaleOutput);620 if (waitTime > 0) {621 LOGGER.info("Wait for at least '" + waitTime + "' seconds before device refresh.");622 CommonUtils.pause(waitTime);623 }624 if (changeConfig) {625 String loc;626 String lang;627 if (initLanguage.contains("_")) {628 lang = initLanguage.split("_")[0];629 loc = initLanguage.split("_")[1];630 } else {631 lang = initLanguage;632 loc = initLanguage;633 }634 LOGGER.info("Update config.properties locale to '" + loc + "' and language to '" + lang + "'.");635 R.CONFIG.put("locale", loc);636 R.CONFIG.put("language", lang);637 }638 actualDeviceLanguage = getDeviceLanguage();639 LOGGER.info("Actual Device Language: " + actualDeviceLanguage);640 if (language.contains(actualDeviceLanguage.toLowerCase()) || actualDeviceLanguage.toLowerCase().contains(language)) {641 status = true;642 } else {643 if (getDeviceLanguage().isEmpty()) {644 LOGGER.info("Adb return empty response without errors.");645 status = true;646 } else {647 currentAndroidVersion = DevicePool.getDevice().getOsVersion();648 LOGGER.info("currentAndroidVersion=" + currentAndroidVersion);649 if (currentAndroidVersion.contains("7.")) {650 LOGGER.info("Adb return language command do not work on some Android 7+ devices." + " Check that there are no error.");651 status = !getDeviceLanguage().toLowerCase().contains("error");652 }653 }654 }655 return status;656 }657 /**658 * getDeviceLanguage659 *660 * @return String661 */662 public String getDeviceLanguage() {663 String locale = executeAdbCommand("shell getprop persist.sys.language");664 if (locale.isEmpty()) {665 locale = executeAdbCommand("shell getprop persist.sys.locale");666 }667 return locale;668 }669 // End Language Change section670 // Fake GPS section671 /**672 * startFakeGPS to emulate GPS location673 *674 * @param location String - existing city (for ex. New York)675 * @return boolean return true if everything is ok.676 */677 public boolean setFakeGPSLocation(String location) {678 return setFakeGPSLocation(location, false);679 }680 /**681 * startFakeGPS to emulate GPS location682 *683 * @param location String - existing city (for ex. New York)684 * @param restartApk - if true DriverPool.restartDriver(true);685 * @return boolean return true if everything is ok.686 */687 public boolean setFakeGPSLocation(String location, boolean restartApk) {688 getDriver();689 boolean res = false;690 installApk(FAKE_GPS_APP_PATH, true);691 String activity = FAKE_GPS_APP_ACTIVITY;692 try {693 forceFakeGPSApkOpen();694 FakeGpsPage fakeGpsPage = new FakeGpsPage(getDriver());695 if (!fakeGpsPage.isOpened(1)) {696 LOGGER.error("Fake GPS application should be open but wasn't. Force opening.");697 openApp(activity);698 CommonUtils.pause(2);699 }700 res = fakeGpsPage.locationSearch(location);701 if (res) {702 LOGGER.info("Set Fake GPS locale: " + location);703 MobileUtils.hideKeyboard();704 fakeGpsPage.clickSetLocation();705 }706 res = true;707 if (restartApk)708 DriverPool.restartDriver(true);709 } catch (Exception e) {710 LOGGER.error("Exception: ", e);711 }712 return res;713 }714 /**715 * stopFakeGPS stop using Fake GPS716 *717 * @return boolean718 */719 public boolean stopFakeGPS() {720 return stopFakeGPS(false);721 }722 /**723 * stopFakeGPS stop using Fake GPS724 *725 * @param restartApk - if true DriverPool.restartDriver(true);726 * @return boolean727 */728 public boolean stopFakeGPS(boolean restartApk) {729 getDriver();730 boolean res = false;731 String activity = FAKE_GPS_APP_ACTIVITY;732 try {733 forceFakeGPSApkOpen();734 FakeGpsPage fakeGpsPage = new FakeGpsPage(getDriver());735 if (!fakeGpsPage.isOpened(1)) {736 LOGGER.error("Fake GPS application should be open but wasn't. Force opening.");737 openApp(activity);738 CommonUtils.pause(2);739 }740 LOGGER.info("STOP Fake GPS locale");741 res = fakeGpsPage.clickStopFakeGps();742 if (restartApk)743 DriverPool.restartDriver(true);744 } catch (Exception e) {745 LOGGER.error("Exception: ", e);746 }747 LOGGER.info("Stop Fake GPS button was clicked: " + res);748 return res;749 }750 /**751 * forceFakeGPSApkOpen752 *753 * @return boolean754 */755 private boolean forceFakeGPSApkOpen() {756 return forceApkOpen(FAKE_GPS_APP_ACTIVITY, FAKE_GPS_APP_PACKAGE, FAKE_GPS_APP_PATH);757 }758 /**759 * forceApkOpen760 *761 * @param activity String762 * @param packageName String763 * @param apkPath String764 * @return boolean765 */766 private boolean forceApkOpen(String activity, String packageName, String apkPath) {767 boolean res;768 int attemps = 3;769 boolean isApkOpened = checkCurrentDeviceFocus(packageName);770 while (!isApkOpened && attemps > 0) {771 LOGGER.info("Apk was not open. Attempt to open...");772 openApp(activity);773 CommonUtils.pause(2);774 isApkOpened = checkCurrentDeviceFocus(packageName);775 attemps--;776 }777 if (!isApkOpened) {778 LOGGER.info("Probably APK was not installed correctly. Try to reinstall.");779 installApk(apkPath, true);780 openApp(activity);781 CommonUtils.pause(2);782 }783 if (checkCurrentDeviceFocus(packageName)) {784 LOGGER.info("On '" + packageName + "' apk page");785 res = true;786 } else {787 LOGGER.error("Not on '" + packageName + "' page after all tries. Please check logs.");788 res = false;789 }790 return res;791 }792 // End of Fake GPS section793 // TimeZone change section794 /**795 * switchDeviceAutoTimeAndTimeZone796 *797 * @param autoSwitch boolean. If true - auto Time and TimeZone will be set798 * as On.799 */800 public void switchDeviceAutoTimeAndTimeZone(boolean autoSwitch) {801 String value = "0";802 if (autoSwitch) {803 value = "1";804 }805 executeAdbCommand("shell settings put global auto_time " + value);806 executeAdbCommand("shell settings put global auto_time_zone " + value);807 }808 /**809 * get Device Time Zone810 *811 * @return DeviceTimeZone812 */813 public DeviceTimeZone getDeviceTimeZone() {814 return getDeviceTimeZone("");815 }816 /**817 * get Device Time Zone. Set default TimeZone818 *819 * @param defaultTZ - default string.820 * @return DeviceTimeZone821 */822 public DeviceTimeZone getDeviceTimeZone(String defaultTZ) {823 getDriver(); // start driver in before class to assign it for particular824 // thread825 DeviceTimeZone dt = new DeviceTimeZone();826 String value = executeAdbCommand("shell settings get global auto_time");827 if (value.contains("0")) {828 dt.setAutoTime(false);829 } else {830 dt.setAutoTime(true);831 }832 value = executeAdbCommand("shell settings get global auto_time_zone");833 if (value.contains("0")) {834 dt.setAutoTimezone(false);835 } else {836 dt.setAutoTimezone(true);837 }838 value = executeAdbCommand("shell settings get system time_12_24");839 if (value.contains("12")) {840 dt.setTimeFormat(TimeFormat.FORMAT_12);841 } else {842 dt.setTimeFormat(TimeFormat.FORMAT_24);843 }844 if (defaultTZ.isEmpty()) {845 value = executeAdbCommand("shell getprop persist.sys.timezone");846 if (!value.isEmpty()) {847 dt.setTimezone(value);848 }849 } else {850 dt.setTimezone(defaultTZ);851 }852 value = executeAdbCommand("shell date -s %mynow%");853 LOGGER.info(value);854 if (!value.isEmpty()) {855 value = convertDateInCorrectString(parseOutputDate(value));856 dt.setSetDeviceDateTime(value);857 LOGGER.info(value);858 }859 dt.setChangeDateTime(false);860 dt.setRefreshDeviceTime(true);861 LOGGER.info(dt.toString());862 return dt;863 }864 /**865 * get Device Actual TimeZone866 *867 * @return String868 */869 public String getDeviceActualTimeZone() {870 String value = executeAdbCommand("shell getprop persist.sys.timezone");871 if (!value.isEmpty()) {872 LOGGER.info(value);873 }874 return value;875 }876 // Start of TimeZone Setting section877 /**878 * set Device TimeZone by using Apk879 *880 * @param timeZone String required timeZone in Android standard format881 * (Europe/London)882 * @param timeFormat String 12 or 24883 * @return boolean884 */885 public boolean setDeviceTimeZone(String timeZone, TimeFormat timeFormat) {886 return setDeviceTimeZone(timeZone, "", timeFormat, ChangeTimeZoneWorkflow.APK);887 }888 /**889 * set Device TimeZone using all supported workflows. By ADB, Settings and890 * Apk891 *892 * @param timeZone String required timeZone893 * @param timeFormat String 12 or 24894 * @param settingsTZ TimeFormat895 * @return boolean896 */897 public boolean setDeviceTimeZone(String timeZone, String settingsTZ, TimeFormat timeFormat) {898 return setDeviceTimeZone(timeZone, settingsTZ, timeFormat, ChangeTimeZoneWorkflow.ALL);899 }900 /**901 * set Device TimeZone. By required workflow: ADB, Settings or APK902 *903 * @param timeZone String required timeZone904 * @param timeFormat String 12 or 24905 * @param settingsTZ TimeFormat906 * @param workflow ChangeTimeZoneWorkflow907 * @return boolean908 */909 public boolean setDeviceTimeZone(String timeZone, String settingsTZ, TimeFormat timeFormat, ChangeTimeZoneWorkflow workflow) {910 boolean changed = false;911 getDriver(); // start driver in before class to assign it for particular912 // thread913 String actualTZ = getDeviceActualTimeZone();914 if (isRequiredTimeZone(actualTZ, timeZone)) {915 LOGGER.info("Required TimeZone is already set.");916 return true;917 }918 String currentAndroidVersion = DevicePool.getDevice().getOsVersion();919 LOGGER.info("currentAndroidVersion=" + currentAndroidVersion);920 if (currentAndroidVersion.contains("7.") ||921 (DevicePool.getDevice().getDeviceType() == DeviceType.Type.ANDROID_TABLET && !currentAndroidVersion.contains("8."))) {922 LOGGER.info("TimeZone changing for Android 7+ and tablets works only by TimeZone changer apk.");923 workflow = ChangeTimeZoneWorkflow.APK;924 }925 // Solution for ADB timezone changing.926 if (ChangeTimeZoneWorkflow.ADB.isSupported(workflow)) {927 LOGGER.info("Try to change TimeZone by ADB");928 LOGGER.info(setDeviceTimeZoneByADB(timeZone, timeFormat, ""));929 changed = applyTZChanges(ChangeTimeZoneWorkflow.ADB, timeZone);930 }931 // Solution for timezone changing by device Settings. (Tested on S7,932 // Note 3, S6, S5).933 if (!changed && ChangeTimeZoneWorkflow.SETTINGS.isSupported(workflow)) {934 LOGGER.info("Try to change TimeZone by Device Settings");935 setDeviceTimeZoneBySetting(timeZone, settingsTZ, timeFormat);936 changed = applyTZChanges(ChangeTimeZoneWorkflow.SETTINGS, timeZone);937 }938 // Solution for using TimeZone Changer apk.939 if (!changed && ChangeTimeZoneWorkflow.APK.isSupported(workflow)) {940 LOGGER.info("Try to change TimeZone by TimeZone Changer apk.");941 setDeviceTimeZoneByChangerApk(timeZone, timeFormat);942 changed = applyTZChanges(ChangeTimeZoneWorkflow.APK, timeZone);943 }944 return changed;945 }946 // End of TimeZone change sections947 /**948 * Open camera on device949 */950 public void openCamera() {951 LOGGER.info("Camera will be opened");952 executeAdbCommand("shell am start -a android.media.action.IMAGE_CAPTURE");953 }954 /**955 * Android camera should be already opened956 */957 public void takePhoto() {958 LOGGER.info("Will take photo");959 executeAdbCommand("shell input keyevent KEYCODE_CAMERA");960 }961 // Private section962 // TimeZone Private methods963 /**964 * setDeviceTimeZoneByADB965 *966 * @param timeZone String967 * @param timeFormat TimeFormat968 * @param deviceSetDate String in format yyyyMMdd.HHmmss. Can be empty.969 * @return String970 */971 private String setDeviceTimeZoneByADB(String timeZone, TimeFormat timeFormat, String deviceSetDate) {972 boolean changeDateTime = true;973 String tzGMT = "";974 if (deviceSetDate.isEmpty()) {975 changeDateTime = false;976 }977 DeviceTimeZone dt = new DeviceTimeZone(false, false, timeFormat, timeZone, tzGMT, deviceSetDate, changeDateTime, true);978 return setDeviceTimeZoneByADB(dt);979 }980 /**981 * setDeviceTimeZoneByADB Automatic date and time = OFF (settings - date and982 * time) adb shell settings put global auto_time 0 Automatic time zone = OFF983 * (settings - date and time) adb shell settings put global auto_time_zone 0984 * <p>985 * Set Time Zone on device adb shell setprop persist.sys.timezone986 * "America/Chicago"987 * <p>988 * Check timezones: <a href=989 * "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">List_of_tz_database_time_zones</a>990 * <p>991 * Check time on device adb shell date -s %mynow%992 * <p>993 * Restart application994 *995 * @param dt DeviceTimeZone996 * @return String actual Device Date and Time997 */998 private String setDeviceTimeZoneByADB(DeviceTimeZone dt) {999 if (dt == null) {1000 LOGGER.error("DeviceTimeZone is not initialised.");1001 dt = new DeviceTimeZone();1002 }1003 LOGGER.info(dt.toString());1004 String autoTime = "0";1005 String autoTimeZone = "0";1006 if (dt.isAutoTime()) {1007 autoTime = "1";1008 }1009 executeAdbCommand("shell settings put global auto_time " + autoTime);1010 if (dt.isAutoTimezone()) {1011 autoTimeZone = "1";1012 }1013 executeAdbCommand("shell settings put global auto_time_zone " + autoTimeZone);1014 setSystemTime(dt.getTimeFormat());1015 if (!dt.getTimezone().isEmpty()) {1016 executeAdbCommand("shell setprop persist.sys.timezone \"" + dt.getTimezone() + "\"");1017 }1018 if (dt.isRefreshDeviceTime()) {1019 executeAdbCommand("shell am broadcast -a android.intent.action.TIME_SET");1020 }1021 if (dt.isChangeDateTime() && !dt.getSetDeviceDateTime().isEmpty()) {1022 // Try to set date for device but it will not work on not rooted1023 // devices1024 executeAdbCommand("shell date " + dt.getSetDeviceDateTime());1025 }1026 String actualDT = executeAdbCommand("shell date -s %mynow%");1027 LOGGER.info(actualDT);1028 return actualDT;1029 }1030 /**1031 * setDeviceTimeZoneBySetting1032 *1033 * @param timeZone String1034 * @param settingsTZ String1035 * @param timeFormat TimeFormat1036 */1037 private void setDeviceTimeZoneBySetting(String timeZone, String settingsTZ, TimeFormat timeFormat) {1038 String actualTZ = getDeviceActualTimeZone();1039 String tz = DeviceTimeZone.getTimezoneOffset(timeZone);1040 if (isRequiredTimeZone(actualTZ, timeZone)) {1041 LOGGER.info("Required timeZone is already set.");1042 return;1043 }1044 try {1045 openDateTimeSettingsSetupWizard(true, timeFormat);1046 String res = getCurrentDeviceFocus();1047 if (res.contains(".Settings$DateTimeSettingsActivity")) {1048 LOGGER.info("On '.Settings$DateTimeSettingsActivity' page");1049 } else {1050 LOGGER.error("Not on '.Settings$DateTimeSettingsActivity' page");1051 }1052 DateTimeSettingsPage dtSettingsPage = new DateTimeSettingsPage(getDriver());1053 if (!dtSettingsPage.isOpened(3)) {1054 openDateTimeSettingsSetupWizard(true, timeFormat);1055 }1056 if (dtSettingsPage.isOpened(3)) {1057 LOGGER.info("Date Time Settings page was open.");1058 } else {1059 LOGGER.error("Date Time Settings page should be open.");1060 }1061 dtSettingsPage.openTimeZoneSetting();1062 dtSettingsPage.selectTimeZone(tz, settingsTZ);1063 dtSettingsPage.clickNextButton();1064 } catch (Exception e) {1065 LOGGER.error("Exception: ", e);1066 }1067 }1068 /**1069 * setDeviceTimeZoneByChangerApk1070 *1071 * @param timeZone String1072 * @param timeFormat TimeFormat1073 */1074 private void setDeviceTimeZoneByChangerApk(String timeZone, TimeFormat timeFormat) {1075 String actualTZ = getDeviceActualTimeZone();1076 String tz = DeviceTimeZone.getTimezoneOffset(timeZone);1077 LOGGER.info("Required TimeZone offset: " + tz);1078 if (isRequiredTimeZone(actualTZ, timeZone)) {1079 LOGGER.info("Required timeZone is already set.");1080 return;1081 }1082 installApk(TZ_CHANGE_APP_PATH, true);1083 try {1084 forceTZChangingApkOpen(true, timeFormat);1085 TZChangerPage tzChangerPage = new TZChangerPage(getDriver());1086 if (tzChangerPage.isOpened(3)) {1087 LOGGER.info("TimeZone changer main page was open.");1088 } else {1089 LOGGER.error("TimeZone changer main page should be open. Retry to open.");1090 openTZChangingApk(true, timeFormat);1091 }1092 tzChangerPage.selectTimeZone(timeZone);1093 } catch (Exception e) {1094 LOGGER.error("Exception: ", e);1095 }1096 }1097 private boolean applyTZChanges(ChangeTimeZoneWorkflow workflow, String expectedZone) {1098 boolean res = false;1099 String actualTZ = getDeviceActualTimeZone();1100 if (isRequiredTimeZone(actualTZ, expectedZone)) {1101 LOGGER.info("Required timeZone '" + expectedZone + "' was set by " + workflow.toString() + ". Restarting driver to apply changes.");1102 DriverPool.restartDriver(true);1103 res = true;1104 } else {1105 LOGGER.error("TimeZone was not changed by " + workflow.toString() + ". Actual TZ is: " + actualTZ);1106 }1107 return res;1108 }1109 /**1110 * comparingExpectedAndActualTZ1111 *1112 * @param actualTZ String1113 * @param expextedTZ String1114 * @return boolean1115 */1116 private boolean isRequiredTimeZone(String actualTZ, String expextedTZ) {1117 boolean res = actualTZ.equals(expextedTZ);1118 if (!res) {1119 String[] actTZ = actualTZ.split("/");1120 String lastActTZ = actTZ[actTZ.length - 1];1121 String[] timeZoneTZ = expextedTZ.split("/");1122 String lastTimeZoneTZ = timeZoneTZ[timeZoneTZ.length - 1];1123 LOGGER.debug("Comparing '" + lastActTZ + "' with '" + lastTimeZoneTZ + "'.");1124 res = lastActTZ.equals(lastTimeZoneTZ);1125 }1126 return res;1127 }1128 /**1129 * @param turnOffAuto boolean1130 * @param timeFormat TimeFormat1131 * @return boolean1132 */1133 private boolean forceTZChangingApkOpen(boolean turnOffAuto, TimeFormat timeFormat) {1134 boolean res = false;1135 String tzPackageName = TZ_CHANGE_APP_PACKAGE;1136 int attemps = 3;1137 boolean isTzOpened = checkCurrentDeviceFocus(tzPackageName);1138 while (!isTzOpened && attemps > 0) {...
Source:NotificationPage.java
...172 notificationService.expandStatusBar();173 }174 try{175 swipe(dismissBtn, notification_scroller);176 if(dismissBtn.getAttribute("enabled").equals("true")) {177 LOGGER.info("Clicking 'Dismiss All Notifications' button...");178 dismissBtn.click();179 } else {180 LOGGER.info("'Dismiss All Notifications' Button is present but disabled, meaning any alerts displayed are not closable. Collapsing tray...");181 pressBack();182 }183 } catch (AssertionError e){184 LOGGER.info("Device tray closed by swiping which means no notifications were present. Proceeding with test.");185 }186 }187 /**188 * cleanNotificationByService189 */190 public void cleanNotificationByService() {...
equals
Using AI Code Generation
1package com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android;2import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification;3import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.NotificationType;4import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.elements.AndroidNotificationElement;5import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.elements.AndroidNotificationElementList;6import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.elements.AndroidNotificationElementList.AndroidNotificationElementListBuilder;7import org.apache.log4j.Logger;8import org.openqa.selenium.By;9import org.openqa.selenium.WebDriver;10import org.openqa.selenium.WebElement;11import org.openqa.selenium.remote.RemoteWebElement;12import org.openqa.selenium.support.ui.ExpectedConditions;13import org.openqa.selenium.support.ui.WebDriverWait;14import java.util.ArrayList;15import java.util.List;16public class AndroidNotification implements Notification {17 private static final Logger LOGGER = Logger.getLogger(AndroidNotification.class);18 private static final String NOTIFICATION_PANEL = "com.android.systemui:id/notification_panel";19 private static final String NOTIFICATION_PANEL_CONTAINER = "com.android.systemui:id/notification_panel_container";20 private static final String NOTIFICATION_PANEL_CONTENT = "com.android.systemui:id/notification_panel_content";21 private static final String NOTIFICATION_PANEL_CONTENT_LIST = "com.android.systemui:id/notification_panel_content_list";22 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER = "com.android.systemui:id/notification_panel_content_list_container";23 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST = "com.android.systemui:id/notification_panel_content_list_container_list";24 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST_ITEM = "com.android.systemui:id/notification_panel_content_list_container_list_item";25 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST_ITEM_CONTENT = "com.android.systemui:id/notification_panel_content_list_container_list_item_content";26 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST_ITEM_CONTENT_TITLE = "com.android.systemui:id/notification_panel_content_list_container_list_item_content_title";27 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST_ITEM_CONTENT_TEXT = "com.android.systemui:id/notification_panel_content_list_container_list_item_content_text";28 private static final String NOTIFICATION_PANEL_CONTENT_LIST_CONTAINER_LIST_ITEM_CONTENT_INFO = "com.android.systemui:id/notification_panel_content_list_container_list_item_content_info";
equals
Using AI Code Generation
1Notification notification = new Notification();2notification.equals(notification);3com.qaprosoft.carina.core.foundation.utils.mobile.notifications.ios.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.ios.Notification();4notification.equals(notification);5com.qaprosoft.carina.core.foundation.utils.mobile.notifications.windows.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.windows.Notification();6notification.equals(notification);7com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification();8notification.equals(notification);9Notification notification = new Notification();10notification.equals(new Notification());11com.qaprosoft.carina.core.foundation.utils.mobile.notifications.ios.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.ios.Notification();12notification.equals(new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.ios.Notification());13com.qaprosoft.carina.core.foundation.utils.mobile.notifications.windows.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.windows.Notification();14notification.equals(new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.windows.Notification());15com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification notification = new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification();16notification.equals(new com.qaprosoft.carina.core.foundation.utils.mobile.notifications.Notification());17Notification notification = new Notification();18notification.equals(new Object());
equals
Using AI Code Generation
1import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.Notification;2public class Test {3 public static void main(String[] args) {4 Notification notif1 = new Notification("test", "test", "test", "test", "test");5 Notification notif2 = new Notification("test", "test", "test", "test", "test");6 System.out.println(notif1.equals(notif2));7 }8}9import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.Notification;10public class Test {11 public static void main(String[] args) {12 Notification notif1 = new Notification("test", "test", "test", "test", "test");13 Notification notif2 = new Notification("test", "test", "test", "test", "test");14 System.out.println(notif1.equals(notif2));15 }16}17import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.Notification;18public class Test {19 public static void main(String[] args) {20 Notification notif1 = new Notification("test", "test", "test", "test", "test");21 Notification notif2 = new Notification("test", "test", "test", "test", "test");22 System.out.println(notif1.equals(notif2));23 }24}25import com.qaprosoft.carina.core.foundation.utils.mobile.notifications.android.Notification;26public class Test {27 public static void main(String[] args) {28 Notification notif1 = new Notification("test", "test", "test", "test", "test");29 Notification notif2 = new Notification("test", "test", "test", "test", "test");30 System.out.println(notif1.equals(notif2));31 }32}33import com
equals
Using AI Code Generation
1public class AndroidNotificationTest {2 public void testEquals() {3 Notification notification1 = new Notification("test", "test", "test", "test");4 Notification notification2 = new Notification("test", "test", "test", "test");5 Assert.assertTrue(notification1.equals(notification2));6 }7}8public class IosNotificationTest {9 public void testEquals() {10 Notification notification1 = new Notification("test", "test", "test", "test");11 Notification notification2 = new Notification("test", "test", "test", "test");12 Assert.assertTrue(notification1.equals(notification2));13 }14}15public class WindowsNotificationTest {16 public void testEquals() {17 Notification notification1 = new Notification("test", "test", "test", "test");18 Notification notification2 = new Notification("test", "test", "test", "test");19 Assert.assertTrue(notification1.equals(notification2));20 }21}22public class MacNotificationTest {23 public void testEquals() {24 Notification notification1 = new Notification("test", "test", "test", "test");25 Notification notification2 = new Notification("test", "test", "test", "test");26 Assert.assertTrue(notification1.equals(notification2));27 }28}29public class TizenNotificationTest {30 public void testEquals() {31 Notification notification1 = new Notification("test", "test", "test", "test");32 Notification notification2 = new Notification("test", "test", "test", "test");33 Assert.assertTrue(notification1.equals(notification2));34 }35}36public class WebNotificationTest {
equals
Using AI Code Generation
1public class Notification {2 private String title;3 private String text;4 private String time;5 private String packageName;6 private String subText;7 private String infoText;8 private String tickerText;9 private String bigText;10 private String summaryText;11 private String bigPicture;12 private String bigPicturePath;13 private String bigPicturePathType;14 private String bigPicturePathName;15 private String bigPicturePathExtension;16 private String bigPicturePathMimeType;17 private String bigPicturePathContent;18 private String bigPicturePathContentEncoding;19 private String bigPicturePathContentDisposition;20 private String bigPicturePathContentLength;21 private String bigPicturePathContentLanguage;22 private String bigPicturePathContentLocation;23 private String bigPicturePathContentRange;24 private String bigPicturePathContentVersion;25 private String bigPicturePathExpires;26 private String bigPicturePathLastModified;27 private String bigPicturePathCacheControl;28 private String bigPicturePathPragma;29 private String bigPicturePathContentTransferEncoding;30 private String bigPicturePathDate;31 private String bigPicturePathAcceptRanges;32 private String bigPicturePathAge;33 private String bigPicturePathAllow;34 private String bigPicturePathContentEncodingValue;35 private String bigPicturePathContentLanguageValue;36 private String bigPicturePathContentLengthValue;37 private String bigPicturePathContentLocationValue;38 private String bigPicturePathContentMD5Value;39 private String bigPicturePathContentRangeValue;40 private String bigPicturePathContentTypeValue;41 private String bigPicturePathDateValue;42 private String bigPicturePathEtagValue;43 private String bigPicturePathExpiresValue;44 private String bigPicturePathLastModifiedValue;45 private String bigPicturePathLocationValue;46 private String bigPicturePathPragmaValue;47 private String bigPicturePathRetryAfterValue;48 private String bigPicturePathServerValue;49 private String bigPicturePathSetCookieValue;50 private String bigPicturePathTrailerValue;51 private String bigPicturePathTransferEncodingValue;52 private String bigPicturePathVaryValue;53 private String bigPicturePathViaValue;54 private String bigPicturePathWarningValue;55 private String bigPicturePathWWWAuthenticateValue;56 private String bigPicturePathContentDispositionValue;57 private String bigPicturePathContentTransferEncodingValue;58 private String bigPicturePathXPoweredByValue;
equals
Using AI Code Generation
1Notification notification = new Notification();2notification.setAppName("Facebook");3notification.setAppPackage("com.facebook.katana");4notification.setAppActivity("com.facebook.katana.LoginActivity");5notification.setNotificationText("Your friend just posted");6notification.setNotificationTitle("Facebook");7notification.setNotificationSubText("Facebook");8notification.setNotificationTicker("Facebook");9notification.setNotificationTime("10:00");10notification.setNotificationDate("10/10/2017");11notification.setNotificationContent("Your friend just posted");12notification.setNotificationBigText("Your friend just posted");13notification.setNotificationBigPicture("Your friend just posted");14notification.setNotificationSummaryText("Your friend just posted");15notification.setNotificationInfoText("Your friend just posted");16notification.setNotificationNumber(1);17notification.setNotificationButton1("Your friend just posted");18notification.setNotificationButton2("Your friend just posted");19notification.setNotificationButton3("Your friend just posted");20notification.setNotificationButton4("Your friend just posted");21notification.setNotificationButton5("Your friend just posted");22Notification notification = new Notification();23notification.setAppName("Facebook");24notification.setAppPackage("com.facebook.katana");25notification.setAppActivity("com.facebook.katana.LoginActivity");26notification.setNotificationText("Your friend just posted");27notification.setNotificationTitle("Facebook");28notification.setNotificationSubText("Facebook");29notification.setNotificationTicker("Facebook");30notification.setNotificationTime("10:00");31notification.setNotificationDate("10/10/2017");32notification.setNotificationContent("Your friend just posted");33notification.setNotificationBigText("Your friend just posted");34notification.setNotificationBigPicture("Your friend just posted");35notification.setNotificationSummaryText("Your friend just posted");36notification.setNotificationInfoText("Your friend just posted");37notification.setNotificationNumber(1);38notification.setNotificationButton1("Your friend just posted");39notification.setNotificationButton2("Your friend just posted");40notification.setNotificationButton3("Your friend just posted");41notification.setNotificationButton4("Your friend just posted");42notification.setNotificationButton5("Your friend just posted");43Notification notification = new Notification();44notification.setAppName("Facebook");45notification.setAppPackage("com.facebook.katana");46notification.setAppActivity("com.facebook.katana.LoginActivity");47notification.setNotificationText("Your friend
equals
Using AI Code Generation
1String text = "Your text here";2String title = "Your title here";3Notification notification = new Notification(text, title);4boolean result = notification.equals(notification);5System.out.println(result);6String text = "Your text here";7String title = "Your title here";8Notification notification = new Notification(text, title);9boolean result = notification.equals(notification);10System.out.println(result);11String text = "Your text here";12String title = "Your title here";13Notification notification = new Notification(text, title);14boolean result = notification.equals(notification);15System.out.println(result);16String text = "Your text here";17String title = "Your title here";18Notification notification = new Notification(text, title);19boolean result = notification.equals(notification);20System.out.println(result);21String text = "Your text here";22String title = "Your title here";23Notification notification = new Notification(text, title);24boolean result = notification.equals(notification);25System.out.println(result);26String text = "Your text here";27String title = "Your title here";28Notification notification = new Notification(text, title);29boolean result = notification.equals(notification);30System.out.println(result);31String text = "Your text here";32String title = "Your title here";33Notification notification = new Notification(text, title);34boolean result = notification.equals(notification);35System.out.println(result);36String text = "Your text here";37String title = "Your title here";38Notification notification = new Notification(text, title);
equals
Using AI Code Generation
1public class NotificationTest {2public void testNotification() {3Notification notification = new Notification();4notification.setAppName("com.example.android.notepad");5notification.setText("Note 1");6notification.setTitle("Notepad");7notification.setPackageName("com.example.android.notepad");8notification.setWhen("2016-05-26 14:31:24");9notification.setTickerText("Note 1");10notification.setSubText("Note 1");11Assert.assertTrue(notification.equals("com.example.android.notepad", "Note 1", "Notepad", "com.example.android.notepad", "2016-05-26 14:31:24", "Note 1", "Note 1"), "Notification is not as expected!");12}13}14public class NotificationTest {15public void testNotification() {16Notification notification = new Notification();17notification.setAppName("com.apple.mobilemail");18notification.setText("Test");19notification.setTitle("Test");20notification.setPackageName("com.apple.mobilemail");21notification.setWhen("2016-05-26 14:31:24");22notification.setTickerText("Test");23notification.setSubText("Test");24Assert.assertTrue(notification.equals("com.apple.mobilemail", "Test", "Test", "com.apple.mobilemail", "2016-05-26 14:31:24", "Test", "Test"), "Notification is not as expected!");25}26}27public class NotificationTest {28public void testNotification() {29Notification notification = new Notification();30notification.setAppName("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");31notification.setText("Calculator");32notification.setTitle("Calculator");33notification.setPackageName("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");34notification.setWhen("2016-05-26 14:31:24");35notification.setTickerText("Calculator");36notification.setSubText("Calculator");37Assert.assertTrue(notification.equals("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App", "Calculator", "Calculator", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App", "2016-05-26 14:31:24", "Calculator", "Calculator
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!