From 32a3ff3114b7608e566dbe254d0ddc646257e4c1 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 7 Mar 2023 14:18:51 +0530 Subject: [PATCH 01/41] (feat): Selenium 4 upgrade part 1 --- automator/pom.xml | 2 +- .../testsigma/automator/actions/Action.java | 3 ++- .../automator/actions/AddonAction.java | 13 +------------ .../actions/CustomExpectedConditions.java | 3 ++- .../automator/actions/DriverAction.java | 9 +++++---- .../automator/actions/ElementAction.java | 18 ++++-------------- .../web/verify/VerifyAlertPresentAction.java | 4 +++- .../web/verify/VerifyBrowserVersionAction.java | 2 +- .../WaitUntilFileDownloadIsCompleteAction.java | 4 +++- .../automator/drivers/WebDriverManager.java | 2 +- .../automator/drivers/web/FirefoxDriver.java | 6 +++--- .../automator/runners/ActionStepExecutor.java | 3 ++- .../automator/suggestion/SuggestionRunner.java | 3 ++- .../web/CheckElementIsInDifferentFrame.java | 4 ++-- .../web/GetListOfSelectWithOptionsAction.java | 2 +- 15 files changed, 33 insertions(+), 45 deletions(-) diff --git a/automator/pom.xml b/automator/pom.xml index 08b14c4db..516864883 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -17,7 +17,7 @@ 2.2.0 2.8.5 7.0.0 - 3.141.59 + 4.8.1 9.4.12.v20180830 4.4 1.5.1 diff --git a/automator/src/com/testsigma/automator/actions/Action.java b/automator/src/com/testsigma/automator/actions/Action.java index 5e60111a7..de579116e 100644 --- a/automator/src/com/testsigma/automator/actions/Action.java +++ b/automator/src/com/testsigma/automator/actions/Action.java @@ -26,6 +26,7 @@ import org.openqa.selenium.*; import org.openqa.selenium.remote.UnreachableBrowserException; +import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -35,7 +36,7 @@ public abstract class Action { private static final int MESSAGE_MAX_SIZE = 500; protected Exception exception; protected Object actualValue; - protected Long timeout = 30L; + protected Duration timeout = Duration.ofSeconds(30); protected ErrorCodes errorCode = ErrorCodes.GENERIC_ERROR; protected Long globalElementTimeOut; protected Map testDataPropertiesEntityMap; diff --git a/automator/src/com/testsigma/automator/actions/AddonAction.java b/automator/src/com/testsigma/automator/actions/AddonAction.java index 4bbe4638c..d8f43afa7 100644 --- a/automator/src/com/testsigma/automator/actions/AddonAction.java +++ b/automator/src/com/testsigma/automator/actions/AddonAction.java @@ -389,7 +389,7 @@ private void handleStaleElementExceptionType(Exception e) { } private void handleInvalidStateExceptionType(Exception e) { - if (e instanceof ElementNotVisibleException) { + if (e instanceof ElementNotInteractableException) { String errorMessage; if (getElementSearchCriteria()) { errorMessage = String.format("Element may be present but not visible in current page. Please verify if the " + @@ -406,17 +406,6 @@ private void handleInvalidStateExceptionType(Exception e) { "If the element is not in view, please try executing step \"Scroll to the element ELEMENT into view\""; setErrorMessage(errorMessage); setErrorCode(ErrorCodes.ELEMENT_CLICK_INTERCEPTED_EXCEPTION); - } else if (e instanceof ElementNotSelectableException) { - String errorMessage; - if (getElementSearchCriteria()) { - errorMessage = String.format("Element is present but it is not selectable. Please check if the select element " + - "corresponding to locator \"%s:%s\" is enabled and interactable.", - elementPropertiesEntity.getFindByType(), elementPropertiesEntity.getLocatorValue()); - } else { - errorMessage = "Element is present but it is not selectable. Please verify if the select element for given criteria is enabled and selectable."; - } - setErrorMessage(errorMessage); - setErrorCode(ErrorCodes.ELEMENT_NOT_SELECTABLE_EXCEPTION); } else { String errorMessage = "Cannot perform any action on the element. Though element may be present, it is in a non-interactive state."; setErrorMessage(errorMessage); diff --git a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java index 743cbb062..075ecede8 100644 --- a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java +++ b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java @@ -7,6 +7,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import java.time.Duration; import java.util.List; import java.util.Set; @@ -204,7 +205,7 @@ final static public void explictWait(WebDriver driver, By by, Integer wait) { return; } if (by != null) { - (new WebDriverWait(driver, wait)).until(ExpectedConditions.presenceOfElementLocated(by)); + (new WebDriverWait(driver, Duration.ofSeconds(wait))).until(ExpectedConditions.presenceOfElementLocated(by)); } } } diff --git a/automator/src/com/testsigma/automator/actions/DriverAction.java b/automator/src/com/testsigma/automator/actions/DriverAction.java index 8962b5b06..5a0a8adf2 100644 --- a/automator/src/com/testsigma/automator/actions/DriverAction.java +++ b/automator/src/com/testsigma/automator/actions/DriverAction.java @@ -15,6 +15,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; +import java.time.Duration; import java.util.concurrent.TimeUnit; @Log4j2 @@ -54,14 +55,14 @@ private void setImplicitTimeout() { } } - protected void setDriverImplicitTimeout(long timeInSeconds) { - getDriver().manage().timeouts().implicitlyWait(timeInSeconds, TimeUnit.SECONDS); + protected void setDriverImplicitTimeout(Duration timeInSeconds) { + getDriver().manage().timeouts().implicitlyWait(timeInSeconds); } private void resetImplicitTimeout() { - if (getGlobalElementTimeOut() != null && getTimeout() != getGlobalElementTimeOut()) { + if (getGlobalElementTimeOut() != null && getTimeout().getSeconds() != getGlobalElementTimeOut()) { log.info("Resetting implicit timeout to Test plan level timeout:" + getGlobalElementTimeOut()); - setDriverImplicitTimeout(getGlobalElementTimeOut()); + setDriverImplicitTimeout(Duration.ofSeconds(getGlobalElementTimeOut())); } } } diff --git a/automator/src/com/testsigma/automator/actions/ElementAction.java b/automator/src/com/testsigma/automator/actions/ElementAction.java index cb43c04c1..9ef38632b 100644 --- a/automator/src/com/testsigma/automator/actions/ElementAction.java +++ b/automator/src/com/testsigma/automator/actions/ElementAction.java @@ -62,7 +62,7 @@ protected void findElement(String elementActionVariableName) throws Exception { log.info("Finding an element for Action variable: " + elementActionVariableName); setElementSearchCriteria(elementActionVariableName); log.info(String.format("Finding element with criteria: %s, Explicit timeout as: %s", elementSearchCriteria, getTimeout())); - CustomExpectedConditions.explictWait(getDriver(), elementSearchCriteria.getBy(), getTimeout().intValue()); + CustomExpectedConditions.explictWait(getDriver(), elementSearchCriteria.getBy(), (int)getTimeout().getSeconds()); elements = getDriver().findElements(elementSearchCriteria.getBy()); log.info("No of elements found: " + elements.size()); if (!elements.isEmpty()) { @@ -267,13 +267,13 @@ private void handleStaleElementExceptionType(Exception e) { } private void handleInvalidStateExceptionType(Exception e) { - if (e instanceof ElementNotVisibleException) { + if (e instanceof ElementNotInteractableException) { String errorMessage; if (elementSearchCriteria != null) { - errorMessage = String.format("Element may be present but not visible in current page. Please verify if the " + + errorMessage = String.format("Element may be present but not interactable in current page. Please verify if the " + "element \"%s:%s\" is pointing to a displayed element.", elementSearchCriteria.getFindByType(), elementSearchCriteria.getByValue()); } else { - errorMessage = "Element may be present but not visible in current page. Please verify the given element criteria is pointing to a displayed/visible element."; + errorMessage = "Element may be present but not interactable in current page. Please verify the given element criteria is pointing to a displayed/visible element."; } setErrorMessage(errorMessage); setErrorCode(ErrorCodes.ELEMENT_NOT_VISIBLE); @@ -283,16 +283,6 @@ private void handleInvalidStateExceptionType(Exception e) { "If the element is not in view, please try executing step \"Scroll to the element ELEMENT into view\""; setErrorMessage(errorMessage); setErrorCode(ErrorCodes.ELEMENT_CLICK_INTERCEPTED_EXCEPTION); - } else if (e instanceof ElementNotSelectableException) { - String errorMessage; - if (elementSearchCriteria != null) { - errorMessage = String.format("Element is present but it is not selectable. Please check if the select element " + - "corresponding to locator \"%s:%s\" is enabled and interactable.", elementSearchCriteria.getFindByType(), elementSearchCriteria.getByValue()); - } else { - errorMessage = "Element is present but it is not selectable. Please verify if the select element for given criteria is enabled and selectable."; - } - setErrorMessage(errorMessage); - setErrorCode(ErrorCodes.ELEMENT_NOT_SELECTABLE_EXCEPTION); } else { String errorMessage = "Cannot perform any action on the element. Though element may be present, it is in a non-interactive state."; setErrorMessage(errorMessage); diff --git a/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java b/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java index 30f54f756..71a682ac8 100644 --- a/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java +++ b/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class VerifyAlertPresentAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully verified Alert's presence in current page."; @@ -13,7 +15,7 @@ public class VerifyAlertPresentAction extends MobileElementAction { @Override public void execute() throws Exception { - WebDriverWait waiter = new WebDriverWait(getDriver(), 30); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(30)); Alert alert = waiter.until(ExpectedConditions.alertIsPresent()); Assert.isTrue(alert != null, ALERT_VERIFICATION_FAILURE); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/web/verify/VerifyBrowserVersionAction.java b/automator/src/com/testsigma/automator/actions/web/verify/VerifyBrowserVersionAction.java index e83763158..92dc78bb4 100644 --- a/automator/src/com/testsigma/automator/actions/web/verify/VerifyBrowserVersionAction.java +++ b/automator/src/com/testsigma/automator/actions/web/verify/VerifyBrowserVersionAction.java @@ -13,7 +13,7 @@ public class VerifyBrowserVersionAction extends ElementAction { @Override public void execute() throws Exception { Capabilities sysCaps = getRemoteWebDriver().getCapabilities(); - setActualValue(sysCaps.getVersion()); + setActualValue(sysCaps.getBrowserVersion()); Assert.isTrue(getTestData().equalsIgnoreCase(getActualValue().toString()), String.format(FAILURE_MESSAGE, getTestData(), getActualValue())); diff --git a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java index e278f2c30..fa04c6d6d 100644 --- a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java +++ b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java @@ -7,6 +7,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class WaitUntilFileDownloadIsCompleteAction extends ElementAction { private static final String SUCCESS_MESSAGE = "Download is completed"; private static final String FAILURE_MESSAGE = "Download is not yet completed. Waited for \"%s\" seconds for download to complete"; @@ -31,7 +33,7 @@ public void execute() throws Exception { " return progress_lst"; //We create a custom wait with long sleep time. Since we are only allowing max of 120 secs for step level timeout(which // may not be sufficient for some downloads), we will be giving additional timeout here. - WebDriverWait waiter = new WebDriverWait(getDriver(), 600, 5000); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(600), Duration.ofSeconds(5000)); boolean isDownloadComplted = waiter.until(CustomExpectedConditions.downloadToBeCompletedInChrome(chromeJavaScript)); Assert.isTrue(isDownloadComplted, String.format(FAILURE_MESSAGE, 600)); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java index cde5a11b8..96f189b26 100644 --- a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java +++ b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java @@ -92,7 +92,7 @@ private void setWebSession(RemoteWebDriver driver) { TestDeviceSettings testDeviceSettings = EnvironmentRunner.getRunnerEnvironmentEntity().getEnvSettings(); String executionUuid = EnvironmentRunner.getRunnerExecutionId(); Capabilities cap = driver.getCapabilities(); - String browserVersion = cap.getVersion(); + String browserVersion = cap.getBrowserVersion(); if (browserVersion.contains(".")) { browserVersion = browserVersion.substring(0, browserVersion.indexOf(".") + 2); diff --git a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java index f64ce0c56..ad373c8c0 100644 --- a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java @@ -11,7 +11,7 @@ import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxProfile; -import org.openqa.selenium.remote.BrowserType; +import org.openqa.selenium.remote.Browser; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -57,7 +57,7 @@ public void setTestsigmaLabCapabilities() throws AutomatorException { } else { super.setTestsigmaLabCapabilities(); } - capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX)); + capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, Browser.FIREFOX)); } protected void setAdditionalCapabilities(List additionalCapabilitiesList) { @@ -97,7 +97,7 @@ protected void setBrowserSpecificCapabilities(List addition profile.setPreference(pro.getKey(), (String) pro.getValue()); } } - capabilities.add(new WebDriverCapability(org.openqa.selenium.firefox.FirefoxDriver.PROFILE, profile)); + capabilities.add(new WebDriverCapability(org.openqa.selenium.firefox.FirefoxDriver.SystemProperty.BROWSER_PROFILE, profile)); single.remove(); } } diff --git a/automator/src/com/testsigma/automator/runners/ActionStepExecutor.java b/automator/src/com/testsigma/automator/runners/ActionStepExecutor.java index de3804ab3..e53535724 100644 --- a/automator/src/com/testsigma/automator/runners/ActionStepExecutor.java +++ b/automator/src/com/testsigma/automator/runners/ActionStepExecutor.java @@ -15,6 +15,7 @@ import org.openqa.selenium.StaleElementReferenceException; import java.lang.reflect.InvocationTargetException; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -39,7 +40,7 @@ public void execute() throws IllegalAccessException, DriverAction snippet = (DriverAction) className.getDeclaredConstructor().newInstance(); snippet.setDriver(DriverManager.getRemoteWebDriver()); - snippet.setTimeout(testCaseStepEntity.getWaitTime().longValue()); + snippet.setTimeout(Duration.ofSeconds(testCaseStepEntity.getWaitTime().longValue())); snippet.setTestDataPropertiesEntityMap(testCaseStepEntity.getTestDataMap()); snippet.setElementPropertiesEntityMap(testCaseStepEntity.getElementsMap()); snippet.setAttributesMap(testCaseStepEntity.getAttributesMap()); diff --git a/automator/src/com/testsigma/automator/suggestion/SuggestionRunner.java b/automator/src/com/testsigma/automator/suggestion/SuggestionRunner.java index 5084cbf16..85960e5ea 100644 --- a/automator/src/com/testsigma/automator/suggestion/SuggestionRunner.java +++ b/automator/src/com/testsigma/automator/suggestion/SuggestionRunner.java @@ -14,6 +14,7 @@ import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.ObjectUtils; +import java.time.Duration; import java.util.*; @Log4j2 @@ -100,7 +101,7 @@ protected SuggestionAction prepareSnippet(String snippetClass, TestPlanRunSettin //convertTestStepDataToNewFormat(testCaseStepEntity); snippet.setDriver(DriverManager.getRemoteWebDriver()); // snippet.setTimeout(testCaseStepEntity.getWaitTime().longValue()); - snippet.setTimeout(0l); + snippet.setTimeout(Duration.ofSeconds(0l)); SuggestionAction.setTestCaseStepEntity(testCaseStepEntity); snippet.setTestDataPropertiesEntityMap(testCaseStepEntity.getTestDataMap()); snippet.setElementPropertiesEntityMap(testCaseStepEntity.getElementsMap()); diff --git a/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java b/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java index b570fd9ab..066e7027f 100644 --- a/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java +++ b/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java @@ -38,7 +38,7 @@ protected void execute() throws Exception { elementInIframe = getDriver().findElement(elementSearchCriteria.getBy()); Map suggestions = new HashMap(); suggestions.put("Frame Name", "");//iframe.getAttribute("name") - suggestions.put("Frame Index", new Integer(i).toString()); + suggestions.put("Frame Index", i.toString()); engineResult.getMetaData().setSuggestions(new JSONObject().put("list", suggestions)); this.suggestionActionResult = SuggestionActionResult.Success; break; @@ -48,7 +48,7 @@ protected void execute() throws Exception { } if (defaultPathName != jsExecutor.executeScript("return window.location.pathname")) { getDriver().switchTo().defaultContent(); - List elements = getDriver().findElementsByXPath("//iframe[@src=\"" + defaultPathName + "\"]"); + List elements = getDriver().findElements(By.xpath("//iframe[@src=\"" + defaultPathName + "\"]")); if (elements.size() > 0) { getDriver().switchTo().frame(elements.get(0)); } diff --git a/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java b/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java index f57fc5619..9c4d8c5e8 100644 --- a/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java +++ b/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java @@ -13,7 +13,7 @@ public class GetListOfSelectWithOptionsAction extends SuggestionAction { @Override protected void execute() throws Exception { - List selectBoxesWithOption = getDriver().findElementsByXPath("//select/option[1]"); + List selectBoxesWithOption = getDriver().findElements(By.xpath("//select/option[1]")); List> list = new ArrayList>(); Integer i = 1; for (WebElement element : selectBoxesWithOption) { From 03a43b61c7e52795c37917501e395168f58c6858 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 7 Mar 2023 15:09:39 +0530 Subject: [PATCH 02/41] TRD-217_upgrade 1. Updating to Appium Java client 8 --- automator/pom.xml | 26 ++++- .../actions/CustomExpectedConditions.java | 3 +- .../automator/actions/DriverAction.java | 1 + .../automator/actions/ElementAction.java | 3 +- .../actions/mobile/ClearElementAction.java | 2 +- .../FindElementByIndexAndClearAction.java | 6 +- .../FindElementByIndexAndSendKeysAction.java | 10 +- .../FindElementByIndexAndTapAction.java | 6 +- .../actions/mobile/FindElementsAction.java | 19 +-- .../actions/mobile/GetUniqueXpathAction.java | 9 +- .../actions/mobile/MobileDriverAction.java | 12 ++ .../actions/mobile/MobileElementAction.java | 71 +++++++++-- .../mobile/MobileInspectorTapOnElement.java | 2 +- .../mobile/MobileNativeCloseSnippet.java | 2 +- .../mobile/MobileNativeHideSnippet.java | 2 +- .../mobile/MobileNativeInstallAppSnippet.java | 7 +- .../mobile/MobileNativeLaunchSnippet.java | 2 +- ...bileNativeOrientationLandscapeSnippet.java | 5 +- ...obileNativeOrientationPortraitSnippet.java | 5 +- .../mobile/MobileNativeRemoveAppSnippet.java | 7 +- .../mobile/MobileNativeResetAppSnippet.java | 2 +- .../mobile/MobileWebViewElementsAction.java | 6 +- .../actions/mobile/PageElementsAction.java | 26 ++++- .../actions/mobile/SendKeysAction.java | 2 +- .../automator/actions/mobile/SwipeAction.java | 18 ++- .../actions/mobile/TapPointAction.java | 18 ++- .../android/MobileNativeLongPressSnippet.java | 18 ++- .../mobile/android/alert/TextAlertAction.java | 4 +- .../ChangeScreenOrientationAction.java | 17 +-- .../generic/GetScreenOrientationAction.java | 4 +- .../android/generic/GoToHomeScreenAction.java | 5 +- .../MobileNativePressBackSpaceAction.java | 5 +- .../press/MobileNativePressEnterAction.java | 4 +- .../press/MobileNativePressSpaceAction.java | 4 +- .../scroll/MobileNativeScrollToAction.java | 3 +- .../MobileNativeScrollToExactAction.java | 3 +- ...sideAnElementFromMiddleToBottomAction.java | 20 +++- ...lInsideAnElementFromMiddleToTopAction.java | 20 +++- ...iveVerifyAlertAbsentWithElementAction.java | 4 +- ...erifyAlertPresentWithButtonTextAction.java | 4 +- ...veVerifyAlertPresentWithElementAction.java | 4 +- ...ativeVerifyAlertPresentWithTextAction.java | 4 +- .../verify/VerifyAlertPresentAction.java | 4 +- .../mobile/app/RunAppInBackgroundAction.java | 4 +- .../mobile/generic/DragAndDropAction.java | 27 ++++- .../ios/app/OpenAppUsingBundleIDAction.java | 6 +- .../ios/app/OpenSafariBrowserAction.java | 5 +- .../ChangeScreenOrientationAction.java | 8 +- .../generic/GetScreenOrientationAction.java | 4 +- .../ios/generic/HideKeyboardAction.java | 110 +++++++++++++----- .../presskey/LongPressOnElementAction.java | 20 +++- .../ios/settings/DisableWIFIAction.java | 7 +- .../mobile/ios/settings/EnableWIFIAction.java | 7 +- .../switchactions/DisableSwitchAction.java | 4 +- .../ios/switchactions/EnableSwitchAction.java | 4 +- .../ios/tap/TapOnElementWithTextAction.java | 22 +++- .../ios/verify/VerifyAlertPresentAction.java | 4 +- .../press/MobileWebPressBackSpaceAction.java | 10 +- .../press/MobileWebPressSpaceAction.java | 11 +- .../verify/VerifyAlertPresentAction.java | 4 +- .../mobile/press/LongPressSnippet.java | 18 ++- .../mobile/press/PressBackSpaceSnippet.java | 11 +- .../mobile/press/PressEnterSnippet.java | 30 ++++- .../actions/mobile/press/PressKeySnippet.java | 12 +- .../mobile/press/PressSpaceSnippet.java | 10 +- ...obileNativeSwipeBottomToMiddleSnippet.java | 19 ++- .../MobileNativeSwipeBottomToTopSnippet.java | 19 ++- ...bileNativeSwipeElementToBottomSnippet.java | 19 ++- ...MobileNativeSwipeElementToLeftSnippet.java | 19 ++- ...obileNativeSwipeElementToRightSnippet.java | 19 ++- .../MobileNativeSwipeElementToTopSnippet.java | 19 ++- .../MobileNativeSwipeLeftToMiddleSnippet.java | 19 ++- .../MobileNativeSwipeLeftToRightSnippet.java | 19 ++- ...obileNativeSwipeMiddleToBottomSnippet.java | 19 ++- .../MobileNativeSwipeMiddleToLeftSnippet.java | 19 ++- ...MobileNativeSwipeMiddleToRightSnippet.java | 19 ++- .../MobileNativeSwipeMiddleToTopSnippet.java | 19 ++- .../MobileNativeSwipeRightToLeftSnippet.java | 19 ++- ...MobileNativeSwipeRightToMiddleSnippet.java | 19 ++- .../MobileNativeSwipeTopToBottomSnippet.java | 19 ++- .../MobileNativeSwipeTopToMiddleSnippet.java | 19 ++- ...leNativeSwitchToContextWithNameAction.java | 17 ++- .../MobileNativeSwitchToNativeAppAction.java | 6 +- .../MobileNativeSwitchToWebviewAction.java | 6 +- .../MobileNativeTapCoordinatesSnippet.java | 18 ++- .../mobile/tap/MobileNativeTapSnippet.java | 19 ++- .../tap/TapOnCoordinatesRelativeToScreen.java | 18 ++- .../TapOnElementUsingCoordinatesAction.java | 20 +++- .../verify/VerifyIfAppInstalledAction.java | 6 +- .../VerifyOrientationIsLandscapeSnippet.java | 6 +- .../VerifyOrientationIsPortraitSnippet.java | 5 +- .../web/verify/VerifyAlertPresentAction.java | 4 +- ...WaitUntilFileDownloadIsCompleteAction.java | 4 +- .../drivers/mobile/AndroidDriver.java | 2 +- .../drivers/mobile/AndroidWebDriver.java | 2 +- .../automator/drivers/mobile/IosDriver.java | 2 +- .../drivers/mobile/IosWebDriver.java | 2 +- .../automator/drivers/web/FirefoxDriver.java | 5 +- .../web/CheckElementIsInDifferentFrame.java | 2 +- .../web/GetListOfSelectWithOptionsAction.java | 2 +- 100 files changed, 951 insertions(+), 236 deletions(-) diff --git a/automator/pom.xml b/automator/pom.xml index 08b14c4db..8b751dc7d 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -16,7 +16,7 @@ 1.5.0 2.2.0 2.8.5 - 7.0.0 + 8.3.0 3.141.59 9.4.12.v20180830 4.4 @@ -298,6 +298,30 @@ log4j-api 2.17.1 + + org.springframework + spring-context + 5.3.20 + compile + + + org.springframework + spring-context + 5.3.20 + compile + + + org.springframework + spring-context + 5.3.20 + compile + + + org.springframework + spring-context + 5.3.20 + compile + diff --git a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java index 743cbb062..075ecede8 100644 --- a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java +++ b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java @@ -7,6 +7,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; +import java.time.Duration; import java.util.List; import java.util.Set; @@ -204,7 +205,7 @@ final static public void explictWait(WebDriver driver, By by, Integer wait) { return; } if (by != null) { - (new WebDriverWait(driver, wait)).until(ExpectedConditions.presenceOfElementLocated(by)); + (new WebDriverWait(driver, Duration.ofSeconds(wait))).until(ExpectedConditions.presenceOfElementLocated(by)); } } } diff --git a/automator/src/com/testsigma/automator/actions/DriverAction.java b/automator/src/com/testsigma/automator/actions/DriverAction.java index 8962b5b06..3fbfdfc08 100644 --- a/automator/src/com/testsigma/automator/actions/DriverAction.java +++ b/automator/src/com/testsigma/automator/actions/DriverAction.java @@ -64,4 +64,5 @@ private void resetImplicitTimeout() { setDriverImplicitTimeout(getGlobalElementTimeOut()); } } + } diff --git a/automator/src/com/testsigma/automator/actions/ElementAction.java b/automator/src/com/testsigma/automator/actions/ElementAction.java index cb43c04c1..1e672328f 100644 --- a/automator/src/com/testsigma/automator/actions/ElementAction.java +++ b/automator/src/com/testsigma/automator/actions/ElementAction.java @@ -26,6 +26,7 @@ import org.openqa.selenium.support.ui.UnexpectedTagNameException; import org.openqa.selenium.support.ui.WebDriverWait; +import java.time.Duration; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -175,7 +176,7 @@ protected void constructElementWithDynamicXpath(String parameterizedXpath, Strin protected WebDriverWait getWebDriverWait() { - return new WebDriverWait(getDriver(), getTimeout()); + return new WebDriverWait(getDriver(), Duration.ofSeconds(getTimeout())); } protected void handleException(Exception e) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/ClearElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/ClearElementAction.java index 2cde95417..86d09fdc0 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ClearElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ClearElementAction.java @@ -22,7 +22,7 @@ public class ClearElementAction extends MobileElementAction { public void execute() throws Exception { AppiumDriver driver = getDriver(); findElement(); - if (driver.getContextHandles().size() > 1) { + if (getContextHandles().size() > 1) { tapByElementCoOrdinates(getElement(), driver); } getElement().clear(); diff --git a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndClearAction.java b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndClearAction.java index 0c50aa5b8..c860a466f 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndClearAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndClearAction.java @@ -31,11 +31,11 @@ public void execute() throws Exception { AppiumDriver driver = getDriver(); List webElements = new ArrayList(); if (getWebViewName() != null && !getWebViewName().equals("null")) { - driver.context(getWebViewName()); + context(getWebViewName()); webElements = driver.findElements(getElementSearchCriteria().getBy()); webElements.get(getIndex()).clear(); - driver.context("NATIVE_APP"); - } else if (driver.getContextHandles().size() > 1) { + context("NATIVE_APP"); + } else if (getContextHandles().size() > 1) { webElements = driver.findElements(getElementSearchCriteria().getBy()); tapByElementCoOrdinates(webElements.get(getIndex()), driver); webElements.get(getIndex()).clear(); diff --git a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java index 628b59090..bec7507f3 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java @@ -1,5 +1,6 @@ package com.testsigma.automator.actions.mobile; +import com.google.common.collect.ImmutableMap; import com.testsigma.automator.entity.Platform; import com.testsigma.automator.actions.ElementSearchCriteria; import io.appium.java_client.AppiumDriver; @@ -7,6 +8,7 @@ import lombok.Setter; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DriverCommand; import java.util.ArrayList; import java.util.List; @@ -21,7 +23,7 @@ public class FindElementByIndexAndSendKeysAction extends MobileElementAction { Integer index; @Getter @Setter - String webViewName; + String webViewName; @Getter @Setter String keys; @@ -34,11 +36,11 @@ public void execute() throws Exception { AppiumDriver driver = getDriver(); List webElements = new ArrayList(); if (getWebViewName() != null && !getWebViewName().equals("null")) { - driver.context(getWebViewName()); + context(getWebViewName()); webElements = driver.findElements(getElementSearchCriteria().getBy()); webElements.get(getIndex()).sendKeys(getKeys()); - driver.context("NATIVE_APP"); - } else if (driver.getContextHandles().size() > 1) { + context("NATIVE_APP"); + } else if (getContextHandles().size() > 1) { webElements = driver.findElements(getElementSearchCriteria().getBy()); tapByElementCoOrdinates(webElements.get(getIndex()), driver); webElements.get(getIndex()).sendKeys(getKeys()); diff --git a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndTapAction.java b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndTapAction.java index e40d46ac0..a32592497 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndTapAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndTapAction.java @@ -34,11 +34,11 @@ public void execute() throws Exception { AppiumDriver driver = getDriver(); List webElements = new ArrayList(); if (getWebViewName() != null && !getWebViewName().equals("null")) { - driver.context(getWebViewName()); + context(getWebViewName()); webElements = driver.findElements(getElementSearchCriteria().getBy()); webElements.get(getIndex()).click(); - driver.context("NATIVE_APP"); - } else if (driver.getContextHandles().size() > 1) { + context("NATIVE_APP"); + } else if (getContextHandles().size() > 1) { webElements = driver.findElements(getElementSearchCriteria().getBy()); tapByElementCoOrdinates(webElements.get(getIndex()), driver); } else { diff --git a/automator/src/com/testsigma/automator/actions/mobile/FindElementsAction.java b/automator/src/com/testsigma/automator/actions/mobile/FindElementsAction.java index 056c6cdc4..0ef7437d3 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/FindElementsAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/FindElementsAction.java @@ -5,13 +5,14 @@ import io.appium.java_client.AppiumDriver; import lombok.Getter; import lombok.Setter; +import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebElement; import java.util.ArrayList; import java.util.List; import java.util.Set; -public class FindElementsAction extends MobileDriverAction { +public class FindElementsAction extends MobileElementAction { @Getter @Setter Platform platform; @@ -23,23 +24,23 @@ public class FindElementsAction extends MobileDriverAction { protected void execute() throws Exception { List mobileElements = new ArrayList(); AppiumDriver driver = getDriver(); - List remoteWebElements = driver.findElements(getElementSearchCriteria().getBy()); - for (RemoteWebElement remoteWebElement : remoteWebElements) { - mobileElements.add(new MobileElement(remoteWebElement, platform)); + List remoteWebElements = driver.findElements(getElementSearchCriteria().getBy()); + for (WebElement remoteWebElement : remoteWebElements) { + mobileElements.add(new MobileElement((RemoteWebElement) remoteWebElement, platform)); } - Set contextNames = getDriver().getContextHandles(); + Set contextNames = getContextHandles(); if (contextNames.size() > 1) { for (String name : contextNames) { if (name.equals("NATIVE_APP") || name.equals("WEBVIEW_chrome")) continue; - driver.context(name); + context(name); remoteWebElements = driver.findElements(getElementSearchCriteria().getBy()); - for (RemoteWebElement remoteWebElement : remoteWebElements) { - MobileWebElement mobileWebElement = new MobileWebElement(remoteWebElement, platform); + for (WebElement remoteWebElement : remoteWebElements) { + MobileWebElement mobileWebElement = new MobileWebElement((RemoteWebElement) remoteWebElement, platform); mobileWebElement.setWebViewName(name); mobileElements.add(mobileWebElement); } - driver.context("NATIVE_APP"); + context("NATIVE_APP"); } } setActualValue(mobileElements); diff --git a/automator/src/com/testsigma/automator/actions/mobile/GetUniqueXpathAction.java b/automator/src/com/testsigma/automator/actions/mobile/GetUniqueXpathAction.java index 6490d8d40..3aa2a64da 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/GetUniqueXpathAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/GetUniqueXpathAction.java @@ -6,12 +6,13 @@ import io.appium.java_client.AppiumDriver; import lombok.Getter; import lombok.Setter; +import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.RemoteWebElement; import java.util.ArrayList; import java.util.List; -public class GetUniqueXpathAction extends MobileDriverAction { +public class GetUniqueXpathAction extends MobileElementAction { @Getter @Setter Platform platform; @@ -23,12 +24,12 @@ public class GetUniqueXpathAction extends MobileDriverAction { @Override protected void execute() throws Exception { AppiumDriver driver = getDriver(); - List webElements = new ArrayList<>(); + List webElements = new ArrayList<>(); ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(FindByType.XPATH, webElement.getXpath()); if(webElement.getWebViewName() != null) { - driver.context(webElement.getWebViewName()); + context(webElement.getWebViewName()); webElements = driver.findElements(elementSearchCriteria.getBy()); - driver.context("NATIVE_APP"); + context("NATIVE_APP"); } else { webElements = driver.findElements(elementSearchCriteria.getBy()); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java index 3500ad915..0336e0e87 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java @@ -9,14 +9,25 @@ package com.testsigma.automator.actions.mobile; +import com.google.common.collect.ImmutableMap; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.DriverAction; import io.appium.java_client.AppiumDriver; +import io.appium.java_client.NoSuchContextException; import io.appium.java_client.remote.MobileCapabilityType; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.Command; +import org.openqa.selenium.remote.DriverCommand; import org.openqa.selenium.remote.Response; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import static com.google.common.base.Preconditions.checkNotNull; + @Log4j2 public abstract class MobileDriverAction extends DriverAction { @@ -59,4 +70,5 @@ protected String getCommandTimeoutValue() { } return commandTimeout; } + } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java index d6aecc950..af05658df 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java @@ -9,19 +9,26 @@ package com.testsigma.automator.actions.mobile; +import com.google.common.collect.ImmutableMap; import com.testsigma.automator.constants.ActionResult; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.ElementAction; import com.testsigma.automator.actions.FindByType; +import io.appium.java_client.AppiumBy; import io.appium.java_client.AppiumDriver; -import io.appium.java_client.android.AndroidElement; -import io.appium.java_client.ios.IOSElement; +import io.appium.java_client.NoSuchContextException; import lombok.Getter; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.*; +import org.openqa.selenium.remote.DriverCommand; +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.remote.Response; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; import static com.testsigma.automator.constants.NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT; @Log4j2 @@ -43,7 +50,8 @@ protected void findElement(String elementActionVariableName) throws Exception { setElementSearchCriteria(elementActionVariableName); AppiumDriver driver = getDriver(); if (this.getElementSearchCriteria().getFindByType().equals(FindByType.ACCESSIBILITY_ID)) { - elements = driver.findElementsByAccessibilityId(getElementSearchCriteria().getByValue()); +// elements = driver.findElementsByAccessibilityId(getElementSearchCriteria().getByValue()); + elements = driver.findElements(AppiumBy.accessibilityId(getElementSearchCriteria().getByValue())); } else { elements = ((WebDriver) driver).findElements(getElementSearchCriteria().getBy()); } @@ -93,13 +101,9 @@ protected void handleStaleelementExecptionOnClickAction() throws Exception { public void tapByElementCoOrdinates(WebElement webElement, AppiumDriver driver) throws Exception { Point loc = webElement.getLocation(); - if (webElement instanceof IOSElement) { - loc = ((IOSElement) webElement).getCenter(); - } else if (webElement instanceof AndroidElement) { - loc = ((AndroidElement) webElement).getCenter(); - } - int x = loc.getX(); - int y = loc.getY(); + Point center = getCenter(webElement); + int x = center.getX(); + int y = center.getY(); TapPointAction tapPointAction = new TapPointAction(); tapPointAction.setTapPoint(new com.testsigma.automator.actions.mobile.TapPoint(x, y)); @@ -110,6 +114,53 @@ public void tapByElementCoOrdinates(WebElement webElement, AppiumDriver driver) throw new Exception("Failed to tap at (" + x + ", " + y + ") : " + tapPointAction.getErrorMessage()); } } + + public Point getCenter(WebElement element) { + Point upperLeft = element.getLocation(); + Dimension dimensions = element.getSize(); + return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2); + } + + public WebDriver context(String name) { + AppiumDriver driver = getDriver(); + checkNotNull(name, "Must supply a context name"); + try { + driver.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); + return driver; + } catch (WebDriverException e) { + throw new NoSuchContextException(e.getMessage(), e); + } + } + + + public Set getContextHandles() { + AppiumDriver driver = getDriver(); + Response response = driver.execute(DriverCommand.GET_CONTEXT_HANDLES, ImmutableMap.of()); + Object value = response.getValue(); + try { + //noinspection unchecked + List returnedValues = (List) value; + return new LinkedHashSet<>(returnedValues); + } catch (ClassCastException ex) { + throw new WebDriverException( + "Returned value cannot be converted to List: " + value, ex); + } + } + + public String getCurrentContext() { + AppiumDriver driver = getDriver(); + Response response = driver.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE, ImmutableMap.of()); + Object value = response.getValue(); + try { + //noinspection unchecked + return (String) value; + } catch (ClassCastException ex) { + throw new WebDriverException( + "Returned value cannot be converted to List: " + value, ex); + } + } + + } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileInspectorTapOnElement.java b/automator/src/com/testsigma/automator/actions/mobile/MobileInspectorTapOnElement.java index 2c829f443..43ad427c8 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileInspectorTapOnElement.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileInspectorTapOnElement.java @@ -26,7 +26,7 @@ public void execute() throws Exception { } else if (!targetElement.isDisplayed()) { throw new AutomatorException(ELEMENT_IS_NOT_DISPLAYED); } - if (driver.getContextHandles().size() > 1) { + if (getContextHandles().size() > 1) { tapByElementCoOrdinates(getElement(), driver); } else { targetElement.click(); diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeCloseSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeCloseSnippet.java index d3cdea061..1ed998eca 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeCloseSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeCloseSnippet.java @@ -18,7 +18,7 @@ public class MobileNativeCloseSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().closeApp(); + getDriver().execute(io.appium.java_client.MobileCommand.CLOSE_APP); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeHideSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeHideSnippet.java index 84a843ab4..8533348c3 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeHideSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeHideSnippet.java @@ -18,7 +18,7 @@ public class MobileNativeHideSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().hideKeyboard(); + getDriver().execute("hideKeyboard"); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeInstallAppSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeInstallAppSnippet.java index 12dd28106..57c65c152 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeInstallAppSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeInstallAppSnippet.java @@ -9,6 +9,8 @@ package com.testsigma.automator.actions.mobile; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import static com.testsigma.automator.constants.NaturalTextActionConstants.TEST_STEP_DATA_MAP_KEY_TEST_DATA; @@ -22,7 +24,10 @@ public class MobileNativeInstallAppSnippet extends MobileElementAction { public void execute() throws Exception { String downloadURL = getTestDataPropertiesEntity(TEST_STEP_DATA_MAP_KEY_TEST_DATA).getTestDataValuePreSignedURL(); downloadURL = (downloadURL == null) ? getTestData() : downloadURL; - getDriver().installApp(downloadURL); + if (getDriver() instanceof AndroidDriver) + ((AndroidDriver) getDriver()).installApp(downloadURL); + else + ((IOSDriver) getDriver()).installApp(downloadURL); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeLaunchSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeLaunchSnippet.java index d6f933a92..977d3df49 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeLaunchSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeLaunchSnippet.java @@ -18,7 +18,7 @@ public class MobileNativeLaunchSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().launchApp(); + getDriver().execute(io.appium.java_client.MobileCommand.LAUNCH_APP); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationLandscapeSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationLandscapeSnippet.java index 1d4f8e90b..de07a07e1 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationLandscapeSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationLandscapeSnippet.java @@ -9,8 +9,10 @@ package com.testsigma.automator.actions.mobile; +import com.google.common.collect.ImmutableMap; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; @Log4j2 public class MobileNativeOrientationLandscapeSnippet extends MobileElementAction { @@ -19,7 +21,8 @@ public class MobileNativeOrientationLandscapeSnippet extends MobileElementAction @Override public void execute() throws Exception { - getDriver().rotate(ScreenOrientation.LANDSCAPE); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, + ImmutableMap.of("orientation", ScreenOrientation.LANDSCAPE.value().toUpperCase())); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java index 195c749e4..1397daa3c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java @@ -9,8 +9,10 @@ package com.testsigma.automator.actions.mobile; +import com.google.common.collect.ImmutableMap; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; @Log4j2 public class MobileNativeOrientationPortraitSnippet extends MobileElementAction { @@ -19,7 +21,8 @@ public class MobileNativeOrientationPortraitSnippet extends MobileElementAction @Override public void execute() throws Exception { - getDriver().rotate(ScreenOrientation.PORTRAIT); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, + ImmutableMap.of("orientation", ScreenOrientation.LANDSCAPE.value().toUpperCase())); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeRemoveAppSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeRemoveAppSnippet.java index b6704d7a6..784a4b9b5 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeRemoveAppSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeRemoveAppSnippet.java @@ -9,6 +9,8 @@ package com.testsigma.automator.actions.mobile; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; @Log4j2 @@ -18,7 +20,10 @@ public class MobileNativeRemoveAppSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().removeApp(getTestData()); + if(getDriver() instanceof AndroidDriver) + ((AndroidDriver)getDriver()).removeApp(getTestData()); + else + ((IOSDriver)getDriver()).removeApp(getTestData()); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeResetAppSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeResetAppSnippet.java index 12678301c..1cd4d975b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeResetAppSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeResetAppSnippet.java @@ -18,7 +18,7 @@ public class MobileNativeResetAppSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().resetApp(); + getDriver().execute("reset"); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileWebViewElementsAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileWebViewElementsAction.java index da27018d2..c0b11d6fd 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileWebViewElementsAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileWebViewElementsAction.java @@ -21,9 +21,11 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; + import javax.xml.parsers.DocumentBuilderFactory; import java.nio.charset.StandardCharsets; + @Log4j2 public class MobileWebViewElementsAction extends PageElementsAction { @@ -44,7 +46,7 @@ public class MobileWebViewElementsAction extends PageElementsAction { @Override public void execute() throws Exception { MobileWebElement mobileWebElement; - getDriver().context(this.context); + context(this.context); elementsDimensions(); String webViewPageSource = getDriver().getPageSource(); log.debug("Page source ::[" + context + "] fetched: " + webViewPageSource); @@ -66,7 +68,7 @@ public void execute() throws Exception { } mobileWebElement = new MobileWebElement(body.cloneNode(true), 1, getPlatform(), this.context); mobileWebElement.setWebViewName(this.context); - getDriver().context("NATIVE_APP"); + context("NATIVE_APP"); setActualValue(mobileWebElement); populateXpath(mobileWebElement); setSuccessMessage(String.format(SUCCESS_MESSAGE, context)); diff --git a/automator/src/com/testsigma/automator/actions/mobile/PageElementsAction.java b/automator/src/com/testsigma/automator/actions/mobile/PageElementsAction.java index 098171761..5a9169086 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/PageElementsAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/PageElementsAction.java @@ -17,6 +17,8 @@ import lombok.extern.log4j.Log4j2; import org.joox.JOOX; import org.joox.Match; +import org.openqa.selenium.remote.Command; +import org.openqa.selenium.remote.Response; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; @@ -28,7 +30,7 @@ import java.util.Set; @Log4j2 -public class PageElementsAction extends MobileDriverAction { +public class PageElementsAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully fetched page source for current page"; @Getter @@ -41,7 +43,7 @@ public class PageElementsAction extends MobileDriverAction { @Override public void execute() throws Exception { MobileElement mobileElement; - getDriver().context("NATIVE_APP"); + context("NATIVE_APP"); String pageSource = getDriver().getPageSource(); log.debug("Page source fetched: " + pageSource); @@ -54,7 +56,7 @@ public void execute() throws Exception { mobileElement = new MobileElement(match.get(0).cloneNode(true), 1, getPlatform()); mobileElement.setParent(null); - Set contextNames = getDriver().getContextHandles(); + Set contextNames = getContextHandles(); mobileElement.setContextNames(contextNames); List webViewElements = new ArrayList<>(); List webViewElementReferences = new ArrayList<>(); @@ -96,7 +98,7 @@ public void execute() throws Exception { } } mobileElement.setWebViewElements(webViewElements); - getDriver().context("NATIVE_APP"); + context("NATIVE_APP"); setActualValue(mobileElement); populateXpath(mobileElement); setSuccessMessage(SUCCESS_MESSAGE); @@ -128,6 +130,22 @@ protected void handleException(Exception e) { setErrorCode(ErrorCodes.PAGE_ELEMENT_LOAD_TIMEOUT); } + public Boolean sessionActive() { + try { + Response response = getDriver().getCommandExecutor().execute(new Command(getDriver().getSessionId(), "status")); + return (response.getStatus() == 0) ? Boolean.FALSE : Boolean.TRUE; + } catch (Exception e) { + log.error(e.getMessage(), e); + return Boolean.FALSE; + } + } + + private void setTimeoutException() { + if (sessionActive() == Boolean.FALSE) { + setErrorMessage("Session expired."); + } + } + protected void populateXpath(MobileElement mobileElement) { mobileElement.populateXpath(); if ((mobileElement.getChildElements() != null) && (mobileElement.getChildElements().size() > 0)) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/SendKeysAction.java b/automator/src/com/testsigma/automator/actions/mobile/SendKeysAction.java index 92d00e877..331accfe6 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/SendKeysAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/SendKeysAction.java @@ -22,7 +22,7 @@ public class SendKeysAction extends MobileElementAction { public void execute() throws Exception { AppiumDriver driver = getDriver(); findElement(); - if (driver.getContextHandles().size() > 1) { + if (getContextHandles().size() > 1) { tapByElementCoOrdinates(getElement(), driver); } getElement().sendKeys(getTestData()); diff --git a/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java b/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java index 53c8b6549..d2d2b8caa 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java @@ -15,8 +15,17 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class SwipeAction extends MobileDriverAction { @@ -29,7 +38,12 @@ public class SwipeAction extends MobileDriverAction { public void execute() throws Exception { PointOption startingPoint = PointOption.point(tapPoints[0].getX(), tapPoints[0].getY()); PointOption endingPoint = PointOption.point(tapPoints[1].getX(), tapPoints[1].getY()); - new TouchAction<>(getDriver()).press(startingPoint) - .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).moveTo(endingPoint).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), tapPoints[0].getX(), tapPoints[0].getY())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), tapPoints[1].getX(), tapPoints[1].getY())) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java b/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java index 514be2566..df951ff5c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java @@ -14,6 +14,16 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; + +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class TapPointAction extends MobileDriverAction { @@ -24,6 +34,12 @@ public class TapPointAction extends MobileDriverAction { @Override public void execute() throws Exception { - new TouchAction<>(getDriver()).tap(PointOption.point(tapPoint.getX(), tapPoint.getY())).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), tapPoint.getX(), tapPoint.getY())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, ofMillis(2))) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/MobileNativeLongPressSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/android/MobileNativeLongPressSnippet.java index ad87cebb1..a241a3843 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/MobileNativeLongPressSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/MobileNativeLongPressSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.ElementOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeLongPressSnippet extends MobileElementAction { @@ -25,11 +34,16 @@ public class MobileNativeLongPressSnippet extends MobileElementAction { @Override public void execute() throws Exception { - TouchAction action = new TouchAction(getDriver()); findElement(); WebElement targetElement = getElement(); Duration duration = Duration.ofSeconds(Long.parseLong(getTestData())); - action.longPress(LongPressOptions.longPressOptions().withElement(ElementOption.element(targetElement)).withDuration(duration)).release().perform(); + PointerInput Finger = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(Finger, 1) + .addAction(Finger.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(Finger.createPointerDown(LEFT.asArg())) + .addAction(new Pause(Finger, duration)) + .addAction(Finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/alert/TextAlertAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/alert/TextAlertAction.java index 0e52c5c00..ace3fa69f 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/alert/TextAlertAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/alert/TextAlertAction.java @@ -10,8 +10,8 @@ package com.testsigma.automator.actions.mobile.android.alert; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.WebElement; @Log4j2 public class TextAlertAction extends MobileElementAction { @@ -25,7 +25,7 @@ public class TextAlertAction extends MobileElementAction { public void execute() throws Exception { constructElementWithDynamicXpath(PARAMETERIZED_XPATH); findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); targetElement.click(); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java index be1c90482..cd2d4c83b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java @@ -1,23 +1,26 @@ package com.testsigma.automator.actions.mobile.android.generic; +import com.google.common.collect.ImmutableMap; +import com.testsigma.automator.actions.mobile.generic.GetScreenOrientationAction; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; public class ChangeScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.ChangeScreenOrientationAction { public void changeOrientation() { - if (getDriver().getOrientation().equals(ScreenOrientation.LANDSCAPE)) { - changeToPortrait(); - } else { - changeToLandscape(); - } + if (getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString().equalsIgnoreCase(ScreenOrientation.LANDSCAPE.value())) { + changeToPortrait(); + } else { + changeToLandscape(); + } } public void changeToPortrait() { - getDriver().rotate(ScreenOrientation.PORTRAIT); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation",ScreenOrientation.PORTRAIT.value().toUpperCase())); } public void changeToLandscape() { - getDriver().rotate(ScreenOrientation.LANDSCAPE); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation",ScreenOrientation.LANDSCAPE.value().toUpperCase())); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/generic/GetScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/generic/GetScreenOrientationAction.java index d70494a3d..7f90a9999 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/generic/GetScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/generic/GetScreenOrientationAction.java @@ -1,10 +1,12 @@ package com.testsigma.automator.actions.mobile.android.generic; +import org.openqa.selenium.remote.DriverCommand; + public class GetScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.GetScreenOrientationAction { public void getOrientation() { - setActualValue(getDriver().getOrientation()); + setActualValue(getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString()); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/generic/GoToHomeScreenAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/generic/GoToHomeScreenAction.java index 4d03b3e84..5962ab9fb 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/generic/GoToHomeScreenAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/generic/GoToHomeScreenAction.java @@ -1,12 +1,13 @@ package com.testsigma.automator.actions.mobile.android.generic; import io.appium.java_client.android.AndroidDriver; -import io.appium.java_client.android.AndroidKeyCode; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; public class GoToHomeScreenAction extends com.testsigma.automator.actions.mobile.generic.GoToHomeScreenAction { public void pressHome() { - ((AndroidDriver) getDriver()).pressKeyCode(AndroidKeyCode.HOME); + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.HOME)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java index 0718e03aa..0264ca2e3 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java @@ -10,7 +10,10 @@ package com.testsigma.automator.actions.mobile.android.press; import com.testsigma.automator.actions.mobile.MobileElementAction; +import com.testsigma.automator.actions.mobile.ios.presskey.PressBackSpaceKeyAction; import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; @Log4j2 @@ -19,7 +22,7 @@ public class MobileNativePressBackSpaceAction extends MobileElementAction { @Override public void execute() throws Exception { - ((AndroidDriver) getDriver()).pressKeyCode(67); + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.DEL)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressEnterAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressEnterAction.java index 890543a23..92deb1f87 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressEnterAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressEnterAction.java @@ -11,6 +11,8 @@ import com.testsigma.automator.actions.mobile.MobileElementAction; import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; @Log4j2 @@ -19,7 +21,7 @@ public class MobileNativePressEnterAction extends MobileElementAction { @Override public void execute() throws Exception { - ((AndroidDriver) getDriver()).pressKeyCode(66); + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.ENTER)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressSpaceAction.java index 79766c939..66c8f12d2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressSpaceAction.java @@ -11,6 +11,8 @@ import com.testsigma.automator.actions.mobile.press.PressSpaceSnippet; import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; @Log4j2 @@ -20,7 +22,7 @@ public class MobileNativePressSpaceAction extends PressSpaceSnippet { @Override public void execute() throws Exception { - ((AndroidDriver) getDriver()).pressKeyCode(62); + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.SPACE)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToAction.java index b53da6de1..5558f3e5c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToAction.java @@ -10,6 +10,7 @@ package com.testsigma.automator.actions.mobile.android.scroll; import com.testsigma.automator.actions.mobile.scroll.ScrollToCenterSnippet; +import io.appium.java_client.AppiumBy; import io.appium.java_client.android.AndroidDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.NotFoundException; @@ -25,7 +26,7 @@ public void execute() throws Exception { String uiSelector = "new UiSelector().textContains(\"" + getTestData() + "\")"; String command = "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(" + uiSelector + ");"; - ((AndroidDriver) getDriver()).findElementByAndroidUIAutomator(command); + ((AndroidDriver) getDriver()).findElement(AppiumBy.ByAndroidUIAutomator.androidUIAutomator(command)); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData())); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToExactAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToExactAction.java index 31950bb69..5997a1e3b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToExactAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/MobileNativeScrollToExactAction.java @@ -10,6 +10,7 @@ package com.testsigma.automator.actions.mobile.android.scroll; import com.testsigma.automator.actions.mobile.scroll.ScrollToCenterSnippet; +import io.appium.java_client.AppiumBy; import io.appium.java_client.android.AndroidDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.NotFoundException; @@ -25,7 +26,7 @@ public void execute() throws Exception { String uiSelector = "new UiSelector().textMatches(\"" + getTestData() + "\")"; String command = "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(" + uiSelector + ");"; - ((AndroidDriver) getDriver()).findElementByAndroidUIAutomator(command); + ((AndroidDriver) getDriver()).findElement(AppiumBy.ByAndroidUIAutomator.androidUIAutomator(command)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java index e60901524..1ae898066 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java @@ -4,9 +4,18 @@ import io.appium.java_client.TouchAction; import io.appium.java_client.touch.WaitOptions; import io.appium.java_client.touch.offset.PointOption; +import org.openqa.selenium.Dimension; import org.openqa.selenium.Rectangle; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class ScrollInsideAnElementFromMiddleToBottomAction extends MobileElementAction { @@ -17,10 +26,13 @@ public class ScrollInsideAnElementFromMiddleToBottomAction extends MobileElement protected void execute() throws Exception { findElement(); Rectangle rect = getElement().getRect(); - PointOption start = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height / 2); - PointOption end = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height); - TouchAction action = new TouchAction(getDriver()); - action.press(start).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(5))).moveTo(end).release().perform(); + PointerInput Finger = new PointerInput(PointerInput.Kind.TOUCH,"finger"); + Sequence swipe = new Sequence(Finger,1) + .addAction(Finger.createPointerMove(ofMillis(0), viewport(), rect.x + rect.width / 2, rect.y + rect.height / 2)) + .addAction(Finger.createPointerDown(LEFT.asArg())) + .addAction(Finger.createPointerMove(ofSeconds(5), viewport(), rect.x + rect.width / 2, rect.y + rect.height)) + .addAction(Finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToTopAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToTopAction.java index 83faf2d25..5a81eba9e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToTopAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToTopAction.java @@ -5,8 +5,17 @@ import io.appium.java_client.touch.WaitOptions; import io.appium.java_client.touch.offset.PointOption; import org.openqa.selenium.Rectangle; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class ScrollInsideAnElementFromMiddleToTopAction extends MobileElementAction { @@ -18,10 +27,13 @@ protected void execute() throws Exception { findElement(); Rectangle rect = getElement().getRect(); - PointOption start = PointOption.point(rect.x + rect.width / 2, rect.y + rect.height / 2); - PointOption end = PointOption.point(rect.x + rect.width / 2, rect.y); - TouchAction action = new TouchAction(getDriver()); - action.press(start).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).moveTo(end).release().perform(); + PointerInput Finger = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(Finger, 1) + .addAction(Finger.createPointerMove(ofMillis(0), viewport(), rect.x + rect.width / 2, rect.y + rect.height / 2)) + .addAction(Finger.createPointerDown(LEFT.asArg())) + .addAction(Finger.createPointerMove(ofSeconds(5), viewport(), rect.x + rect.width / 2, rect.y)) + .addAction(Finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertAbsentWithElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertAbsentWithElementAction.java index f7cc231ef..bf71a742c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertAbsentWithElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertAbsentWithElementAction.java @@ -10,9 +10,9 @@ package com.testsigma.automator.actions.mobile.android.verify; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.NotFoundException; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; @Log4j2 @@ -31,7 +31,7 @@ public void execute() throws Exception { setSuccessMessage(SUCCESS_MESSAGE); return; } - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); Assert.isTrue(!targetElement.isDisplayed(), String.format("The Alert contains element with given locator %s:%s which is not expected.", getElementSearchCriteria().getFindByType(), getElementSearchCriteria().getByValue())); diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithButtonTextAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithButtonTextAction.java index cb66745d6..3ab0237d6 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithButtonTextAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithButtonTextAction.java @@ -10,8 +10,8 @@ package com.testsigma.automator.actions.mobile.android.verify; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; @Log4j2 @@ -30,7 +30,7 @@ public void execute() throws Exception { verifyAlertPresence(FAILURE_MESSAGE_NULL); constructElementWithDynamicXpath(PARAMETERIZED_XPATH); findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); Assert.isTrue(targetElement.isDisplayed(), String.format(FAILURE_MESSAGE_NOT_DISPLAYED, getTestData())); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithElementAction.java index 2130a909c..02104e506 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithElementAction.java @@ -10,8 +10,8 @@ package com.testsigma.automator.actions.mobile.android.verify; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; @Log4j2 @@ -24,7 +24,7 @@ public class MobileNativeVerifyAlertPresentWithElementAction extends MobileEleme public void execute() throws Exception { verifyAlertPresence(FAILURE_MESSAGE_NULL); findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); Assert.isTrue(targetElement.isDisplayed(), String.format("The Alert` with locator %s:%s is not in displayed on the page", getElementSearchCriteria().getFindByType(), getElementSearchCriteria().getByValue())); diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithTextAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithTextAction.java index a4f0bd1ff..f1c1b3c8e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithTextAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/verify/MobileNativeVerifyAlertPresentWithTextAction.java @@ -10,8 +10,8 @@ package com.testsigma.automator.actions.mobile.android.verify; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; import static com.testsigma.automator.constants.NaturalTextActionConstants.TESTS_TEP_DATA_MAP_KEY_ELEMENT; @@ -31,7 +31,7 @@ public void execute() throws Exception { verifyAlertPresence(FAILURE_MESSAGE_NULL); constructElementWithDynamicXpath(PARAMETERIZED_XPATH, TESTS_TEP_DATA_MAP_KEY_ELEMENT, TEST_STEP_DATA_MAP_KEY_TEST_DATA, null, false); findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); Assert.isTrue(targetElement.isDisplayed(), String.format("The Alert with text %s is not displayed in this page", getTestData())); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/verify/VerifyAlertPresentAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/verify/VerifyAlertPresentAction.java index 1507fa83f..f64c2608f 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/verify/VerifyAlertPresentAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/verify/VerifyAlertPresentAction.java @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class VerifyAlertPresentAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully verified Alert's presence in current page."; @@ -13,7 +15,7 @@ public class VerifyAlertPresentAction extends MobileElementAction { @Override public void execute() throws Exception { - WebDriverWait waiter = new WebDriverWait(getDriver(), 30); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(30)); Alert alert = waiter.until(ExpectedConditions.alertIsPresent()); Assert.isTrue(alert != null, ALERT_VERIFICATION_FAILURE); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/mobile/app/RunAppInBackgroundAction.java b/automator/src/com/testsigma/automator/actions/mobile/app/RunAppInBackgroundAction.java index 7b544b410..2986782f4 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/app/RunAppInBackgroundAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/app/RunAppInBackgroundAction.java @@ -1,7 +1,9 @@ package com.testsigma.automator.actions.mobile.app; +import com.google.common.collect.ImmutableMap; import com.testsigma.automator.formatters.NumberFormatter; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.MobileCommand; import java.time.Duration; @@ -13,7 +15,7 @@ public class RunAppInBackgroundAction extends MobileElementAction { protected void execute() throws Exception { int noOfSeconds = NumberFormatter.getIntegerValue(getTestData(), String.format(FAILURE_NOT_A_NUMBER, getTestData())); Duration duration = Duration.ofSeconds(noOfSeconds); - getDriver().runAppInBackground(duration); + getDriver().execute(MobileCommand.RUN_APP_IN_BACKGROUND,ImmutableMap.of("seconds", (double)duration.toMillis() / 1000.0)); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData())); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/generic/DragAndDropAction.java b/automator/src/com/testsigma/automator/actions/mobile/generic/DragAndDropAction.java index 33357b0da..a46e4c87d 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/generic/DragAndDropAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/generic/DragAndDropAction.java @@ -6,9 +6,19 @@ import io.appium.java_client.touch.LongPressOptions; import io.appium.java_client.touch.WaitOptions; import io.appium.java_client.touch.offset.ElementOption; +import io.appium.java_client.touch.offset.PointOption; +import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class DragAndDropAction extends MobileElementAction { @Override @@ -17,11 +27,18 @@ protected void execute() throws Exception { WebElement targetElementFrom = getElement(); findElement(NaturalTextActionConstants.TEST_STEP_DATA_MAP_KEY_TO_ELEMENT); WebElement targetElementTo = getElement(); - TouchAction builder = new TouchAction(getDriver()); - TouchAction dragAndDrop = builder.longPress(LongPressOptions.longPressOptions() - .withElement(ElementOption.element(targetElementFrom))). - waitAction(WaitOptions.waitOptions(Duration.ofMillis(3000))).moveTo(ElementOption.element(targetElementTo)).release(); - dragAndDrop.perform(); + int middleXCoordinate_dragElement = targetElementFrom.getLocation().x + (targetElementFrom.getSize().width / 2 ); + int middleYCoordinate_dragElement = targetElementFrom.getLocation().y + (targetElementFrom.getSize().height / 2 ); + int middleXCoordinate_dropElement = targetElementTo.getLocation().x + (targetElementTo.getSize().width / 2 ); + int middleYCoordinate_dropElement = targetElementTo.getLocation().x + (targetElementTo.getSize().height / 2 ); + PointerInput Finger = new PointerInput(PointerInput.Kind.TOUCH,"finger"); + Sequence swipe = new Sequence(Finger,1) + .addAction(Finger.createPointerMove(ofMillis(0), viewport(), middleXCoordinate_dragElement, middleYCoordinate_dragElement)) + .addAction(Finger.createPointerDown(LEFT.asArg())) + .addAction(Finger.createPointerMove(ofSeconds(5), viewport(), middleXCoordinate_dropElement, middleYCoordinate_dropElement)) + .addAction(Finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); + setSuccessMessage("Successfully executed drag and drop of element."); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenAppUsingBundleIDAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenAppUsingBundleIDAction.java index 3af3622d8..a7525728e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenAppUsingBundleIDAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenAppUsingBundleIDAction.java @@ -1,6 +1,10 @@ package com.testsigma.automator.actions.mobile.ios.app; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.MobileCommand; +import io.appium.java_client.ios.IOSDriver; + +import java.util.HashMap; public class OpenAppUsingBundleIDAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully opened app with bundle id %s"; @@ -9,7 +13,7 @@ public class OpenAppUsingBundleIDAction extends MobileElementAction { @Override protected void execute() throws Exception { - getDriver().activateApp(getTestData().trim()); + ((IOSDriver) getDriver()).activateApp(getTestData().trim()); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData())); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenSafariBrowserAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenSafariBrowserAction.java index a0864175a..2d829566d 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenSafariBrowserAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/app/OpenSafariBrowserAction.java @@ -1,6 +1,9 @@ package com.testsigma.automator.actions.mobile.ios.app; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.ios.IOSDriver; + +import java.util.HashMap; public class OpenSafariBrowserAction extends MobileElementAction { @@ -8,7 +11,7 @@ public class OpenSafariBrowserAction extends MobileElementAction { @Override protected void execute() throws Exception { - getDriver().activateApp("com.apple.mobilesafari"); + ((IOSDriver) getDriver()).activateApp("com.apple.mobilesafari"); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java index a7ba63280..38134c3d7 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java @@ -1,11 +1,13 @@ package com.testsigma.automator.actions.mobile.ios.generic; +import com.google.common.collect.ImmutableMap; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; public class ChangeScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.ChangeScreenOrientationAction { public void changeOrientation() { - if (getDriver().getOrientation().equals(ScreenOrientation.LANDSCAPE)) { + if (getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString().equalsIgnoreCase(ScreenOrientation.LANDSCAPE.value())) { changeToPortrait(); } else { changeToLandscape(); @@ -13,11 +15,11 @@ public void changeOrientation() { } public void changeToPortrait() { - getDriver().rotate(ScreenOrientation.PORTRAIT); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation",ScreenOrientation.PORTRAIT.value().toUpperCase())); } public void changeToLandscape() { - getDriver().rotate(ScreenOrientation.LANDSCAPE); + getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation",ScreenOrientation.LANDSCAPE.value().toUpperCase())); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/GetScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/GetScreenOrientationAction.java index 273e73b33..b9cc1a6dd 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/GetScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/GetScreenOrientationAction.java @@ -1,10 +1,12 @@ package com.testsigma.automator.actions.mobile.ios.generic; +import org.openqa.selenium.remote.DriverCommand; + public class GetScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.GetScreenOrientationAction { public void getOrientation() { - setActualValue(getDriver().getOrientation()); + setActualValue(getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString()); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 525f494ff..929fba0ee 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -1,15 +1,34 @@ package com.testsigma.automator.actions.mobile.ios.generic; +import com.testsigma.automator.actions.mobile.MobileElement; import com.testsigma.automator.actions.mobile.MobileElementAction; +import com.testsigma.automator.actions.mobile.SendKeysAction; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.HidesKeyboard; +import io.appium.java_client.HidesKeyboardWithKeyName; import io.appium.java_client.TouchAction; import io.appium.java_client.ios.IOSDriver; -import io.appium.java_client.ios.IOSElement; import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import org.springframework.util.Assert; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; +import static io.appium.java_client.MobileCommand.hideKeyboardCommand; @Log4j2 public class HideKeyboardAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Hide Keyboard executed successfully."; @@ -17,35 +36,53 @@ public class HideKeyboardAction extends MobileElementAction { @Override protected void execute() throws Exception { - IOSDriver driver = (IOSDriver) getDriver(); int i = 0; - while (driver.isKeyboardShown() && i < 5) { + boolean keyboardShown = true; + while (i < 5) { if (i == 0) { - clickOnHideKeyBoardAccessibilityID(); + switchToActiveElementAndPressEnter(); } else if (i == 1) { - clickOnReturnToHideKeyboard(); + hideKeyboardByTappingOutsideKeyboard(); } else if (i == 2) { - sendKeysToHideKeyboard(Keys.RETURN); + clickOnReturnKeys(); } else if (i == 3) { hideKeyboardByTappingOutsideKeyboard(); } else { break; } i++; + if (!isKeyboardShown()) { + keyboardShown = false; + break; + } } - Assert.isTrue(Boolean.FALSE.equals(driver.isKeyboardShown()), FAILURE_MESSAGE); + Assert.isTrue(Boolean.FALSE.equals(keyboardShown), FAILURE_MESSAGE); setSuccessMessage(SUCCESS_MESSAGE); } + private void switchToActiveElementAndPressEnter() { + try { + getDriver().switchTo().activeElement().sendKeys(Keys.RETURN); + log.error("Hide keyboard by switching to active element and clicking enter"); + } catch (Exception e) { + log.error("Could not hide keyboard by switching to active element and clicking enter"); + } + } + private void hideKeyboardByTappingOutsideKeyboard() { String keyboardElementClassName = "XCUIElementTypeKeyboard"; log.info("Using KEYBOARD ELEMENT(Tap/touch above keyboard) to hide keyboard, Element classname:" + keyboardElementClassName); try { - IOSElement element = (IOSElement) getDriver().findElementByClassName(keyboardElementClassName); - Point keyboardPoint = element.getLocation(); - TouchAction touchAction = new TouchAction(getDriver()); - touchAction.tap(PointOption.point(keyboardPoint.getX() + 2, keyboardPoint.getY() - 2)).perform(); + WebElement element = getDriver().findElement(By.className(keyboardElementClassName)); + Point keyboardPoint = element.getLocation(); + PointerInput finger = new PointerInput(TOUCH,"finger"); + Sequence tap = new Sequence(finger,1) + .addAction(finger.createPointerMove(ofMillis(0), viewport(),keyboardPoint.getX() + 2, keyboardPoint.getY() - 2)) + .addAction(finger.createPointerDown(LEFT.asArg())) + .addAction(new Pause(finger,ofMillis(1))) + .addAction(finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); try { Thread.sleep(200); } catch (InterruptedException e) { @@ -57,35 +94,50 @@ private void hideKeyboardByTappingOutsideKeyboard() { } } - private void sendKeysToHideKeyboard(Keys aReturn) { + private void clickOnReturnKeys() { - log.info("Using SEND KEYS to hide keyboard, key sent:" + aReturn.toString()); - try { - getDriver().getKeyboard().sendKeys(aReturn); - log.info("Using SEND KEYS to hide keyboard didn't throw any exception,key sent:" + aReturn); - } catch (Exception e) { - log.error("**Tried to hide keyboard using SEND KEYS,Key sent:" + aReturn + " ***", e); - } + List.of("Return", "return", "done", "Done", "search", "Search", "Next", "next", "Go", "go").forEach(button -> { + try { + getDriver().findElement(By.xpath("//*[contains(@name, '" + button + "')]")).click(); + } catch (Exception e) { + log.error(e, e); + } + try { + getDriver().findElement(By.name(button)); + } catch (Exception e) { + log.error(e, e); + } + } + ); } - private void clickOnReturnToHideKeyboard() { - log.info("Using PRESS on return key to hide keyboard"); + private void clickOnHideKeyBoardAccessibilityID() { + log.info("Using Hide Keyboard accessibilityId to hide keyboard"); try { - getDriver().getKeyboard().pressKey(Keys.RETURN); - log.info("Using PRESS on return key to hide keyboard didn't throw any exception"); + getDriver().findElement(AppiumBy.accessibilityId("Hide keyboard")).click(); + log.info("Using Hide Keyboard accessibilityId to hide keyboard didn't throw any exception"); } catch (Exception e) { - log.error("**Tried to hide keyboard using PRESS on return key ***", e); + log.error("**Tried to hide keyboard using Hide Keyboard id***", e); } + } - private void clickOnHideKeyBoardAccessibilityID() { - log.info("Using Hide Keyboard accessibilityId to hide keyboard"); + protected boolean isKeyboardShown() { + setDriverImplicitTimeout(5); + boolean keyboardShown = ((IOSDriver) getDriver()).isKeyboardShown(); + resetImplicitTimeout(); + return keyboardShown; + } + + protected void resetImplicitTimeout() { try { - getDriver().findElementByAccessibilityId("Hide keyboard").click(); - log.info("Using Hide Keyboard accessibilityId to hide keyboard didn't throw any exception"); + long webkitResponseTimeout = (Long) getDriver().getCapabilities().getCapability("webkitResponseTimeout"); + setDriverImplicitTimeout(webkitResponseTimeout / 1000); } catch (Exception e) { - log.error("**Tried to hide keyboard using Hide Keyboard id***", e); + setDriverImplicitTimeout(getGlobalElementTimeOut()); } } + + } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java index f8603e5a0..a42ef1fdc 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java @@ -5,8 +5,18 @@ import io.appium.java_client.TouchAction; import io.appium.java_client.touch.LongPressOptions; import io.appium.java_client.touch.offset.ElementOption; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class LongPressOnElementAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully pressed on the given element for %s seconds."; @@ -16,10 +26,16 @@ public class LongPressOnElementAction extends MobileElementAction { @Override protected void execute() throws Exception { findElement(); - TouchAction action = new TouchAction(getDriver()); + WebElement targetElement = getElement(); int noOfSeconds = NumberFormatter.getIntegerValue(getTestData(), String.format(FAILURE_NOT_A_NUMBER, getTestData())); Duration time = Duration.ofSeconds(noOfSeconds); - action.longPress(LongPressOptions.longPressOptions().withElement(ElementOption.element(getElement())).withDuration(time)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, time)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData())); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java index e18512868..9bf63ec01 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java @@ -1,10 +1,13 @@ package com.testsigma.automator.actions.mobile.ios.settings; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import java.util.HashMap; + @Log4j2 public class DisableWIFIAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully disabled WIFI."; @@ -17,7 +20,7 @@ public class DisableWIFIAction extends MobileElementAction { @Override protected void execute() throws Exception { //Switch to settings app - getDriver().activateApp("com.apple.Preferences"); + ((IOSDriver) getDriver()).activateApp("com.apple.Preferences"); WebElement wifiSettingsElement = getDriver().findElement(By.name("Wi-Fi")); wifiSettingsElement.click(); String switchValue = null; @@ -38,7 +41,7 @@ protected void execute() throws Exception { boolean appRedirected = false; if (parentAppBundleID != null) { try { - getDriver().activateApp(parentAppBundleID); + ((IOSDriver) getDriver()).activateApp(parentAppBundleID); appRedirected = true; } catch (Exception e) { //We ignore this exception, User can execute open app with bundleId step if switching failed. diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java index 8f90717c8..42c1fc7ed 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java @@ -1,10 +1,13 @@ package com.testsigma.automator.actions.mobile.ios.settings; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import java.util.HashMap; + @Log4j2 public class EnableWIFIAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully enabled WIFI."; @@ -17,7 +20,7 @@ public class EnableWIFIAction extends MobileElementAction { @Override protected void execute() throws Exception { //Switch to settings app - getDriver().activateApp("com.apple.Preferences"); + ((IOSDriver) getDriver()).activateApp("com.apple.Preferences"); WebElement wifiSettingsElement = getDriver().findElement(By.name("Wi-Fi")); wifiSettingsElement.click(); String switchValue = null; @@ -38,7 +41,7 @@ protected void execute() throws Exception { boolean appRedirected = false; if (parentAppBundleID != null) { try { - getDriver().activateApp(parentAppBundleID); + ((IOSDriver) getDriver()).activateApp(parentAppBundleID); appRedirected = true; } catch (Exception e) { //We ignore this exception, User can execute open app with bundleId step if switching failed. diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/DisableSwitchAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/DisableSwitchAction.java index 14ce8eb17..09498d83a 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/DisableSwitchAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/DisableSwitchAction.java @@ -2,7 +2,7 @@ import com.testsigma.automator.actions.constants.ActionConstants; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; public class DisableSwitchAction extends MobileElementAction { @@ -15,7 +15,7 @@ public class DisableSwitchAction extends MobileElementAction { @Override protected void execute() throws Exception { findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); String value = targetElement.getAttribute(ActionConstants.ATTRIBUTE_VALUE); Assert.notNull(value, String.format(FAILURE_NULL_VALUE, getFindByType(), getLocatorValue(), targetElement.getAttribute(ActionConstants.ATTRIBUTE_TYPE))); if (!value.equals("0")) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/EnableSwitchAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/EnableSwitchAction.java index 1e02bc16b..18fc4aad2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/EnableSwitchAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/switchactions/EnableSwitchAction.java @@ -2,7 +2,7 @@ import com.testsigma.automator.actions.constants.ActionConstants; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.MobileElement; +import org.openqa.selenium.WebElement; import org.springframework.util.Assert; public class EnableSwitchAction extends MobileElementAction { @@ -15,7 +15,7 @@ public class EnableSwitchAction extends MobileElementAction { @Override protected void execute() throws Exception { findElement(); - MobileElement targetElement = (MobileElement) getElement(); + WebElement targetElement = (WebElement) getElement(); String value = targetElement.getAttribute(ActionConstants.ATTRIBUTE_VALUE); Assert.notNull(value, String.format(FAILURE_NULL_VALUE, getFindByType(), getLocatorValue(), targetElement.getAttribute(ActionConstants.ATTRIBUTE_TYPE))); if (value.equals("0")) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/tap/TapOnElementWithTextAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/tap/TapOnElementWithTextAction.java index a1e4671cf..ce1b4b2aa 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/tap/TapOnElementWithTextAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/tap/TapOnElementWithTextAction.java @@ -1,19 +1,35 @@ package com.testsigma.automator.actions.mobile.ios.tap; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; import io.appium.java_client.TouchAction; import io.appium.java_client.touch.TapOptions; import io.appium.java_client.touch.offset.ElementOption; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; + +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class TapOnElementWithTextAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Tap on element executed successfully"; @Override protected void execute() throws Exception { - TouchAction action = new TouchAction(getDriver()); - WebElement targetElement = getDriver().findElementByAccessibilityId(getTestData()); - action.tap(TapOptions.tapOptions().withElement(ElementOption.element(targetElement))).perform(); + WebElement targetElement = getDriver().findElement(AppiumBy.accessibilityId(getTestData())); + PointerInput Finger = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(Finger, 1) + .addAction(Finger.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(Finger.createPointerDown(LEFT.asArg())) + .addAction(new Pause(Finger, ofMillis(2))) + .addAction(Finger.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/verify/VerifyAlertPresentAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/verify/VerifyAlertPresentAction.java index 5f396c2bc..908f974be 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/verify/VerifyAlertPresentAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/verify/VerifyAlertPresentAction.java @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class VerifyAlertPresentAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully verified Alert's presence in current page."; @@ -13,7 +15,7 @@ public class VerifyAlertPresentAction extends MobileElementAction { @Override public void execute() throws Exception { - WebDriverWait waiter = new WebDriverWait(getDriver(), 30); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofMillis(30)); Alert alert = waiter.until(ExpectedConditions.alertIsPresent()); Assert.isTrue(alert != null, ALERT_VERIFICATION_FAILURE); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java index cb5ace35e..e40462cbe 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java @@ -10,7 +10,13 @@ package com.testsigma.automator.actions.mobile.mobileweb.press; import com.testsigma.automator.actions.mobile.press.PressBackSpaceSnippet; +import io.appium.java_client.AppiumBy; import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; +import io.appium.java_client.ios.IOSDriver; +import io.appium.java_client.ios.IOSMobileCommandHelper; +import io.appium.java_client.ios.touch.IOSPressOptions; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.Keys; @@ -24,9 +30,9 @@ public class MobileWebPressBackSpaceAction extends PressBackSpaceSnippet { @Override public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { - ((AndroidDriver) getDriver()).pressKeyCode(67); + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.DEL)); } else { - getDriver().getKeyboard().pressKey(Keys.BACK_SPACE); + getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java index 11a153b8a..822fe9739 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java @@ -10,6 +10,11 @@ package com.testsigma.automator.actions.mobile.mobileweb.press; import com.testsigma.automator.actions.mobile.press.PressSpaceSnippet; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; +import io.appium.java_client.ios.IOSMobileCommandHelper; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Keys; @@ -20,7 +25,11 @@ public class MobileWebPressSpaceAction extends PressSpaceSnippet { @Override public void execute() throws Exception { - getDriver().getKeyboard().pressKey(Keys.SPACE); + if (getDriver() instanceof AndroidDriver) { + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.SPACE)); + } else { + getDriver().findElement(AppiumBy.accessibilityId("space")).click(); + } setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/verify/VerifyAlertPresentAction.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/verify/VerifyAlertPresentAction.java index 3dfe7c335..49dec88b9 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/verify/VerifyAlertPresentAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/verify/VerifyAlertPresentAction.java @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class VerifyAlertPresentAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully verified Alert's presence in current page."; @@ -13,7 +15,7 @@ public class VerifyAlertPresentAction extends MobileElementAction { @Override public void execute() throws Exception { - WebDriverWait waiter = new WebDriverWait(getDriver(), 30); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(30)); Alert alert = waiter.until(ExpectedConditions.alertIsPresent()); Assert.isTrue(alert != null, ALERT_VERIFICATION_FAILURE); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java index a163fde01..961f758d2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class LongPressSnippet extends MobileElementAction { @@ -25,11 +34,16 @@ public class LongPressSnippet extends MobileElementAction { @Override public void execute() throws Exception { - TouchAction action = new TouchAction(getDriver()); findElement(); WebElement targetElement = getElement(); Duration duration = Duration.ofSeconds(Long.parseLong(getTestData())); - action.press(PointOption.point(targetElement.getLocation())).waitAction(WaitOptions.waitOptions(duration)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, duration)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java index dd70132af..dd0847c6b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java @@ -10,6 +10,11 @@ package com.testsigma.automator.actions.mobile.press; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.Keys; @@ -22,7 +27,11 @@ public class PressBackSpaceSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().getKeyboard().pressKey(Keys.BACK_SPACE); + if (getDriver() instanceof AndroidDriver) { + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.DEL)); + } else { + getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); + } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java index db4af806e..b526064a2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java @@ -10,10 +10,17 @@ package com.testsigma.automator.actions.mobile.press; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.By; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.Keys; +import java.util.List; + @Log4j2 public class PressEnterSnippet extends MobileElementAction { @@ -22,10 +29,31 @@ public class PressEnterSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().getKeyboard().pressKey(Keys.ENTER); + if (getDriver() instanceof AndroidDriver) { + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.ENTER)); + } else { + getDriver().findElement(AppiumBy.accessibilityId("Done")).click(); + } setSuccessMessage(SUCCESS_MESSAGE); } + private void clickOnReturnKeys() { + + List.of("Return", "return", "done", "Done", "search", "Search", "Next", "next", "Go", "go").forEach(button -> { + try { + getDriver().findElement(By.xpath("//*[contains(@name, '" + button + "')]")).click(); + } catch (Exception e) { + log.error(e, e); + } + try { + getDriver().findElement(By.name(button)); + } catch (Exception e) { + log.error(e, e); + } + } + ); + } + @Override protected void handleException(Exception e) { super.handleException(e); diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java index d543a6c48..7a6806418 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java @@ -11,6 +11,10 @@ import com.testsigma.automator.actions.constants.ErrorCodes; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.Keys; @@ -23,8 +27,12 @@ public class PressKeySnippet extends MobileElementAction { @Override public void execute() throws Exception { - - getDriver().getKeyboard().pressKey(Keys.valueOf(getTestData().toUpperCase())); +// getDriver().getKeyboard().pressKey(Keys.valueOf(getTestData().toUpperCase())); + if (getDriver() instanceof AndroidDriver) { + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.valueOf(getTestData().toUpperCase()))); + } else { + getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); + } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java index ed7d69322..396eaf650 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java @@ -10,6 +10,10 @@ package com.testsigma.automator.actions.mobile.press; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.nativekey.AndroidKey; +import io.appium.java_client.android.nativekey.KeyEvent; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.Keys; @@ -22,7 +26,11 @@ public class PressSpaceSnippet extends MobileElementAction { @Override public void execute() throws Exception { - getDriver().getKeyboard().pressKey(Keys.SPACE); + if (getDriver() instanceof AndroidDriver) { + ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.SPACE)); + } else { + getDriver().findElement(AppiumBy.accessibilityId("space")).click(); + } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java index de51ff8b2..c9e134d69 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeBottomToMiddleSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.90); int endy = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java index d7e4d79a3..ca4b7af17 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeBottomToTopSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.90); int endy = (int) (size.height * 0.10); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java index 5ee6f7de4..c9a035d01 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java @@ -16,8 +16,17 @@ import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeElementToBottomSnippet extends MobileElementAction { @@ -33,9 +42,13 @@ public void execute() throws Exception { int endy = (int) (size.height * 0.9); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(x, y)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java index de5b7dafa..26a233ab9 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java @@ -16,8 +16,17 @@ import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeElementToLeftSnippet extends MobileElementAction { @@ -33,9 +42,13 @@ public void execute() throws Exception { int endy = targetElement.getLocation().getY(); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(x, y)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java index 324a96df0..1417918ea 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java @@ -16,8 +16,17 @@ import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeElementToRightSnippet extends MobileElementAction { @@ -34,9 +43,13 @@ public void execute() throws Exception { int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(x, y)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java index 51b88967a..da7815ecb 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java @@ -16,8 +16,17 @@ import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeElementToTopSnippet extends MobileElementAction { @@ -33,9 +42,13 @@ public void execute() throws Exception { int endy = (int) (size.height * 0.9); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(x, y)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java index 8a197c80f..d68945d5a 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeLeftToMiddleSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.10); int endx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java index cbcedce40..58be498e6 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeLeftToRightSnippet extends MobileElementAction { @@ -30,9 +39,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.10); int endx = (int) (size.width * 0.90); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java index e9f974da0..6a3388e12 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeMiddleToBottomSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); int endy = (int) (size.height * 0.90); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java index 03d8f516a..e516cebf5 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeMiddleToLeftSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int endx = (int) (size.width * 0.10); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java index bf72e9e4c..3921be703 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeMiddleToRightSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int endx = (int) (size.width * 0.90); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java index bcbeaa840..c7e6f7fec 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeMiddleToTopSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); int endy = (int) (size.height * 0.10); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java index 5fd0d4a95..cf551769e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeRightToLeftSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.90); int endx = (int) (size.width * 0.10); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java index 9f1c42f74..97c7cd281 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeRightToMiddleSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.90); int endx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(endx, starty)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java index 19ced5d18..b21018f61 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeTopToBottomSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.10); int endy = (int) (size.height * 0.90); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java index df27ac757..30c8b806b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java @@ -15,8 +15,17 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import java.time.Duration; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static java.time.Duration.ofSeconds; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeSwipeTopToMiddleSnippet extends MobileElementAction { @@ -29,9 +38,13 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.10); int endy = (int) (size.height * 0.50); - TouchAction swipeTo = new TouchAction(getDriver()); - Duration d = Duration.ofSeconds(5); - swipeTo.press(PointOption.point(startx, starty)).waitAction(WaitOptions.waitOptions(d)).moveTo(PointOption.point(startx, endy)).release().perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToContextWithNameAction.java b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToContextWithNameAction.java index c88590c9f..a1109328e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToContextWithNameAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToContextWithNameAction.java @@ -1,7 +1,11 @@ package com.testsigma.automator.actions.mobile.switchactions; +import com.google.common.collect.ImmutableMap; +import com.testsigma.automator.actions.mobile.MobileDriverAction; import com.testsigma.automator.actions.mobile.MobileElementAction; import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.remote.DriverCommand; +import org.openqa.selenium.remote.Response; import java.util.Set; @@ -15,9 +19,16 @@ public class MobileNativeSwitchToContextWithNameAction extends MobileElementActi @Override protected void execute() throws Exception { - currentContext = getDriver().getContext(); - contexts = getDriver().getContextHandles(); - getDriver().context(getTestData()); + currentContext = getCurrentContext(); + contexts = getContextHandles(); + if (contexts.size() < 2) { + //In browserstack webviews will not be listed on first call. + Thread.sleep(2000); + contexts = getContextHandles(); + } + contexts.remove("NATIVE_APP"); + contexts.remove("WEBVIEW_chrome"); + context(getTestData()); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData(), contexts)); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToNativeAppAction.java b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToNativeAppAction.java index d2747c8ec..bca5ecf88 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToNativeAppAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToNativeAppAction.java @@ -16,9 +16,9 @@ public class MobileNativeSwitchToNativeAppAction extends MobileElementAction { @Override protected void execute() throws Exception { - currentContext = getDriver().getContext(); - contexts = getDriver().getContextHandles(); - getDriver().context("NATIVE_APP"); + currentContext = getCurrentContext(); + contexts = getContextHandles(); + context("NATIVE_APP"); setSuccessMessage(String.format(SUCCESS_MESSAGE, "NATIVE_APP", contexts)); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToWebviewAction.java b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToWebviewAction.java index c4abd6b89..5be34bc63 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToWebviewAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/switchactions/MobileNativeSwitchToWebviewAction.java @@ -17,9 +17,9 @@ public class MobileNativeSwitchToWebviewAction extends MobileElementAction { @Override protected void execute() throws Exception { - currentContext = getDriver().getContext(); + currentContext = getCurrentContext(); String contextName = null; - contexts = getDriver().getContextHandles(); + contexts = getContextHandles(); for (String context : contexts) { //WEBVIEW_Chrome is a chrome context, not a webview inside app. if (context != null && context.toUpperCase().startsWith("WEB") && !context.equalsIgnoreCase("WEBVIEW_chrome")) { @@ -29,7 +29,7 @@ protected void execute() throws Exception { } Assert.notNull(contextName, String.format(FAILURE_MESSAGE_NOT_AVAILABLE, contexts, currentContext)); Assert.isTrue(Boolean.FALSE.equals(currentContext.equalsIgnoreCase(contextName)), FAILURE_MESSAGE); - getDriver().context(contextName); + context(contextName); setSuccessMessage(String.format(SUCCESS_MESSAGE, contextName, contexts)); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java index f33fd7343..eddb00217 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java @@ -15,6 +15,16 @@ import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidArgumentException; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; + +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeTapCoordinatesSnippet extends MobileElementAction { @@ -26,7 +36,13 @@ public void execute() throws Exception { String[] splitCoordiantes = getTestData().split(","); int x = Integer.parseInt(splitCoordiantes[0]); int y = Integer.parseInt(splitCoordiantes[1]); - new TouchAction(getDriver()).tap(PointOption.point(x, y)).perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, ofMillis(2))) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java index a88a71d0b..2c996fd22 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java @@ -14,6 +14,16 @@ import io.appium.java_client.touch.TapOptions; import io.appium.java_client.touch.offset.ElementOption; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; + +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; @Log4j2 public class MobileNativeTapSnippet extends MobileElementAction { @@ -22,9 +32,14 @@ public class MobileNativeTapSnippet extends MobileElementAction { @Override public void execute() throws Exception { - TouchAction action = new TouchAction(getDriver()); findElement(); - action.tap(TapOptions.tapOptions().withElement(ElementOption.element(getElement()))).perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), getElement().getLocation().getX(), getElement().getLocation().getY())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, ofMillis(2))) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java index c266367c2..cdb922e95 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java @@ -5,8 +5,18 @@ import io.appium.java_client.TouchAction; import io.appium.java_client.touch.offset.PointOption; import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; import org.springframework.util.Assert; +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; + public class TapOnCoordinatesRelativeToScreen extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully tapped at given location.
Window dimensions(width,height):%s , %s
" + "Tap Location(x,y): %s , %s"; @@ -31,7 +41,13 @@ protected void execute() throws Exception { Dimension screenDimension = getDriver().manage().window().getSize(); Double clickLocationX = (xPercent * screenDimension.getWidth() / 100); Double clickLocationY = (yPercent * screenDimension.getHeight() / 100); - new TouchAction(getDriver()).tap(PointOption.point(clickLocationX.intValue(), clickLocationY.intValue())).perform(); + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), clickLocationX.intValue(), clickLocationY.intValue())) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, ofMillis(2))) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(String.format(SUCCESS_MESSAGE, screenDimension.getWidth(), screenDimension.getHeight(), clickLocationX, clickLocationY)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java index 992b3a1ad..64afef524 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java @@ -4,6 +4,16 @@ import io.appium.java_client.TouchAction; import io.appium.java_client.touch.offset.PointOption; import org.openqa.selenium.Rectangle; +import org.openqa.selenium.interactions.Pause; +import org.openqa.selenium.interactions.PointerInput; +import org.openqa.selenium.interactions.Sequence; + +import java.util.Arrays; + +import static java.time.Duration.ofMillis; +import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; +import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; +import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; public class TapOnElementUsingCoordinatesAction extends MobileElementAction { @@ -15,8 +25,14 @@ protected void execute() throws Exception { findElement(); Rectangle rect = getElement().getRect(); - TouchAction action = new TouchAction(getDriver()); - action.tap(PointOption.point(rect.x + rect.width / 2, rect.y + rect.height / 2)).perform(); + + PointerInput FINGER = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(FINGER, 1) + .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), rect.x + rect.width /2, rect.y + rect.height /2)) + .addAction(FINGER.createPointerDown(LEFT.asArg())) + .addAction(new Pause(FINGER, ofMillis(2))) + .addAction(FINGER.createPointerUp(LEFT.asArg())); + getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyIfAppInstalledAction.java b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyIfAppInstalledAction.java index d6dc94663..a8d6fff06 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyIfAppInstalledAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyIfAppInstalledAction.java @@ -1,6 +1,9 @@ package com.testsigma.automator.actions.mobile.verify; +import com.google.common.collect.ImmutableMap; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.MobileCommand; +import org.openqa.selenium.remote.Response; import org.springframework.util.Assert; public class VerifyIfAppInstalledAction extends MobileElementAction { @@ -9,7 +12,8 @@ public class VerifyIfAppInstalledAction extends MobileElementAction { @Override protected void execute() throws Exception { - boolean appInstalled = getDriver().isAppInstalled(getTestData()); + Response response = getDriver().execute("isAppInstalled", ImmutableMap.of("bundleId", getTestData())); + boolean appInstalled = Boolean.parseBoolean(response.getValue().toString()); Assert.isTrue(appInstalled, String.format(FAILURE_MESSAGE, getTestData())); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java index 003d0d0bc..d28d73b86 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java @@ -12,6 +12,8 @@ import com.testsigma.automator.actions.mobile.MobileDriverAction; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; +import org.openqa.selenium.remote.Response; import org.springframework.util.Assert; @Log4j2 @@ -23,8 +25,8 @@ public class VerifyOrientationIsLandscapeSnippet extends MobileDriverAction { @Override public void execute() throws Exception { - ScreenOrientation orientation = getDriver().getOrientation(); - Assert.isTrue(orientation.equals(ScreenOrientation.LANDSCAPE), String.format(SCREEN_NOT_LANDSCAPE, orientation)); + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).toString(); + Assert.isTrue(orientation.equalsIgnoreCase(String.valueOf(ScreenOrientation.LANDSCAPE)), String.format(SCREEN_NOT_LANDSCAPE, orientation)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java index b538adb6e..88e2e8b6b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java @@ -12,6 +12,7 @@ import com.testsigma.automator.actions.mobile.MobileDriverAction; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.ScreenOrientation; +import org.openqa.selenium.remote.DriverCommand; import org.springframework.util.Assert; @Log4j2 @@ -23,8 +24,8 @@ public class VerifyOrientationIsPortraitSnippet extends MobileDriverAction { @Override public void execute() throws Exception { - ScreenOrientation orientation = getDriver().getOrientation(); - Assert.isTrue(orientation.equals(ScreenOrientation.PORTRAIT), String.format(SCREEN_NOT_PORTRAIT, orientation)); + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).toString(); + Assert.isTrue(orientation.equalsIgnoreCase(ScreenOrientation.PORTRAIT.toString()), String.format(SCREEN_NOT_PORTRAIT, orientation)); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java b/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java index 30f54f756..71a682ac8 100644 --- a/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java +++ b/automator/src/com/testsigma/automator/actions/web/verify/VerifyAlertPresentAction.java @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class VerifyAlertPresentAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully verified Alert's presence in current page."; @@ -13,7 +15,7 @@ public class VerifyAlertPresentAction extends MobileElementAction { @Override public void execute() throws Exception { - WebDriverWait waiter = new WebDriverWait(getDriver(), 30); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(30)); Alert alert = waiter.until(ExpectedConditions.alertIsPresent()); Assert.isTrue(alert != null, ALERT_VERIFICATION_FAILURE); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java index e278f2c30..5ab2a0e32 100644 --- a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java +++ b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java @@ -7,6 +7,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.springframework.util.Assert; +import java.time.Duration; + public class WaitUntilFileDownloadIsCompleteAction extends ElementAction { private static final String SUCCESS_MESSAGE = "Download is completed"; private static final String FAILURE_MESSAGE = "Download is not yet completed. Waited for \"%s\" seconds for download to complete"; @@ -31,7 +33,7 @@ public void execute() throws Exception { " return progress_lst"; //We create a custom wait with long sleep time. Since we are only allowing max of 120 secs for step level timeout(which // may not be sufficient for some downloads), we will be giving additional timeout here. - WebDriverWait waiter = new WebDriverWait(getDriver(), 600, 5000); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofMillis(600), Duration.ofMillis(500)); boolean isDownloadComplted = waiter.until(CustomExpectedConditions.downloadToBeCompletedInChrome(chromeJavaScript)); Assert.isTrue(isDownloadComplted, String.format(FAILURE_MESSAGE, 600)); setSuccessMessage(SUCCESS_MESSAGE); diff --git a/automator/src/com/testsigma/automator/drivers/mobile/AndroidDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/AndroidDriver.java index 169e792d8..6ebb3dd11 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/AndroidDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/AndroidDriver.java @@ -29,6 +29,6 @@ protected void setHybridCapabilities() throws AutomatorException, MalformedURLEx @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { - remoteWebDriver = new io.appium.java_client.android.AndroidDriver<>(remoteServerURL, desiredCapabilities); + remoteWebDriver = new io.appium.java_client.android.AndroidDriver(remoteServerURL, desiredCapabilities); } } diff --git a/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java index 89961303d..f26983f5c 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java @@ -39,6 +39,6 @@ protected void setHybridCapabilities() throws AutomatorException, MalformedURLEx @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { - remoteWebDriver = new io.appium.java_client.android.AndroidDriver<>(remoteServerURL, desiredCapabilities); + remoteWebDriver = new io.appium.java_client.android.AndroidDriver(remoteServerURL, desiredCapabilities); } } diff --git a/automator/src/com/testsigma/automator/drivers/mobile/IosDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/IosDriver.java index 3b837a92b..1d0524c66 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/IosDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/IosDriver.java @@ -46,6 +46,6 @@ protected void setHybridCapabilities() throws AutomatorException, MalformedURLEx @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { - remoteWebDriver = new IOSDriver<>(getRemoteServerURL(), desiredCapabilities); + remoteWebDriver = new IOSDriver(getRemoteServerURL(), desiredCapabilities); } } diff --git a/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java index e81c54386..4904b7a02 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java @@ -28,6 +28,6 @@ protected void setCommonCapabilities() throws AutomatorException { @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { - remoteWebDriver = new IOSDriver<>(getRemoteServerURL(), desiredCapabilities); + remoteWebDriver = new IOSDriver(getRemoteServerURL(), desiredCapabilities); } } diff --git a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java index f64ce0c56..2cbc45419 100644 --- a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java @@ -8,10 +8,11 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.log4j.Log4j2; +import org.openqa.selenium.Capabilities; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxProfile; -import org.openqa.selenium.remote.BrowserType; +import org.openqa.selenium.remote.Browser; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -57,7 +58,7 @@ public void setTestsigmaLabCapabilities() throws AutomatorException { } else { super.setTestsigmaLabCapabilities(); } - capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX)); + capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, Browser.FIREFOX)); } protected void setAdditionalCapabilities(List additionalCapabilitiesList) { diff --git a/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java b/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java index b570fd9ab..afa2dfc49 100644 --- a/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java +++ b/automator/src/com/testsigma/automator/suggestion/actions/web/CheckElementIsInDifferentFrame.java @@ -48,7 +48,7 @@ protected void execute() throws Exception { } if (defaultPathName != jsExecutor.executeScript("return window.location.pathname")) { getDriver().switchTo().defaultContent(); - List elements = getDriver().findElementsByXPath("//iframe[@src=\"" + defaultPathName + "\"]"); + List elements = getDriver().findElements(By.xpath("//iframe[@src=\"" + defaultPathName + "\"]")); if (elements.size() > 0) { getDriver().switchTo().frame(elements.get(0)); } diff --git a/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java b/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java index f57fc5619..9c4d8c5e8 100644 --- a/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java +++ b/automator/src/com/testsigma/automator/suggestion/actions/web/GetListOfSelectWithOptionsAction.java @@ -13,7 +13,7 @@ public class GetListOfSelectWithOptionsAction extends SuggestionAction { @Override protected void execute() throws Exception { - List selectBoxesWithOption = getDriver().findElementsByXPath("//select/option[1]"); + List selectBoxesWithOption = getDriver().findElements(By.xpath("//select/option[1]")); List> list = new ArrayList>(); Integer i = 1; for (WebElement element : selectBoxesWithOption) { From db730c965504a89b088776ea01d195ed86f3d58e Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 7 Mar 2023 15:38:48 +0530 Subject: [PATCH 03/41] (feat): merge conflicts --- .../mobile/ios/IosMobileAutomationServer.java | 2 +- .../automator/actions/ElementAction.java | 2 +- .../actions/mobile/MobileElementAction.java | 7 +++---- .../mobile/ios/generic/HideKeyboardAction.java | 18 +++++------------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java index 4ca2e38f1..56f555ab8 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java @@ -58,7 +58,7 @@ public void createSession(String uniqueId) throws MobileAutomationServerSessionE desiredCapabilities.setCapability("xcodeOrgId", "6F4CKCA4LX"); desiredCapabilities.setCapability("xcodeSigningId", "iPhone Developer"); desiredCapabilities.setCapability("app", "/Users/vikram/ios-apps/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app"); - device.setRemoteWebDriver(new IOSDriver<>(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), + device.setRemoteWebDriver(new IOSDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), desiredCapabilities)); } catch (Exception e) { throw new MobileAutomationServerSessionException(e.getMessage()); diff --git a/automator/src/com/testsigma/automator/actions/ElementAction.java b/automator/src/com/testsigma/automator/actions/ElementAction.java index dc9e64005..3272f9e2b 100644 --- a/automator/src/com/testsigma/automator/actions/ElementAction.java +++ b/automator/src/com/testsigma/automator/actions/ElementAction.java @@ -176,7 +176,7 @@ protected void constructElementWithDynamicXpath(String parameterizedXpath, Strin protected WebDriverWait getWebDriverWait() { - return new WebDriverWait(getDriver(), Duration.ofSeconds(getTimeout())); + return new WebDriverWait(getDriver(), getTimeout()); } protected void handleException(Exception e) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java index af05658df..b37281b3c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java @@ -14,14 +14,13 @@ import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.ElementAction; import com.testsigma.automator.actions.FindByType; -import io.appium.java_client.AppiumBy; import io.appium.java_client.AppiumDriver; +import io.appium.java_client.MobileBy; import io.appium.java_client.NoSuchContextException; import lombok.Getter; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.*; import org.openqa.selenium.remote.DriverCommand; -import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.remote.Response; import java.util.LinkedHashSet; @@ -51,7 +50,7 @@ protected void findElement(String elementActionVariableName) throws Exception { AppiumDriver driver = getDriver(); if (this.getElementSearchCriteria().getFindByType().equals(FindByType.ACCESSIBILITY_ID)) { // elements = driver.findElementsByAccessibilityId(getElementSearchCriteria().getByValue()); - elements = driver.findElements(AppiumBy.accessibilityId(getElementSearchCriteria().getByValue())); + elements = driver.findElements(MobileBy.AccessibilityId(getElementSearchCriteria().getByValue())); } else { elements = ((WebDriver) driver).findElements(getElementSearchCriteria().getBy()); } @@ -78,7 +77,7 @@ protected void verifyAlertPresence(String failureMessage) throws AutomatorExcept } protected void handleStaleelementExecptionOnClickAction() throws Exception { - int retriesTimeout = (getTimeout().intValue()) > 0 ? (getTimeout().intValue()) : 30; + int retriesTimeout = (getTimeout().toSecondsPart()) > 0 ? (getTimeout().toSecondsPart()) : 30; Long pollInterval = 500l; By by = getElementSearchCriteria().getBy(); for (int i = 1; i <= (retriesTimeout * 2); i++) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 929fba0ee..4a8b04dea 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -1,14 +1,8 @@ package com.testsigma.automator.actions.mobile.ios.generic; -import com.testsigma.automator.actions.mobile.MobileElement; import com.testsigma.automator.actions.mobile.MobileElementAction; -import com.testsigma.automator.actions.mobile.SendKeysAction; -import io.appium.java_client.AppiumBy; -import io.appium.java_client.HidesKeyboard; -import io.appium.java_client.HidesKeyboardWithKeyName; -import io.appium.java_client.TouchAction; +import io.appium.java_client.MobileBy; import io.appium.java_client.ios.IOSDriver; -import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -20,7 +14,6 @@ import org.springframework.util.Assert; import java.time.Duration; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -28,7 +21,6 @@ import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH; import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT; import static org.openqa.selenium.interactions.PointerInput.Origin.viewport; -import static io.appium.java_client.MobileCommand.hideKeyboardCommand; @Log4j2 public class HideKeyboardAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Hide Keyboard executed successfully."; @@ -114,7 +106,7 @@ private void clickOnReturnKeys() { private void clickOnHideKeyBoardAccessibilityID() { log.info("Using Hide Keyboard accessibilityId to hide keyboard"); try { - getDriver().findElement(AppiumBy.accessibilityId("Hide keyboard")).click(); + getDriver().findElement(MobileBy.AccessibilityId("Hide keyboard")).click(); log.info("Using Hide Keyboard accessibilityId to hide keyboard didn't throw any exception"); } catch (Exception e) { log.error("**Tried to hide keyboard using Hide Keyboard id***", e); @@ -123,7 +115,7 @@ private void clickOnHideKeyBoardAccessibilityID() { } protected boolean isKeyboardShown() { - setDriverImplicitTimeout(5); + setDriverImplicitTimeout(Duration.ofSeconds(5)); boolean keyboardShown = ((IOSDriver) getDriver()).isKeyboardShown(); resetImplicitTimeout(); return keyboardShown; @@ -132,9 +124,9 @@ protected boolean isKeyboardShown() { protected void resetImplicitTimeout() { try { long webkitResponseTimeout = (Long) getDriver().getCapabilities().getCapability("webkitResponseTimeout"); - setDriverImplicitTimeout(webkitResponseTimeout / 1000); + setDriverImplicitTimeout(Duration.ofSeconds(webkitResponseTimeout / 1000)); } catch (Exception e) { - setDriverImplicitTimeout(getGlobalElementTimeOut()); + setDriverImplicitTimeout(Duration.ofSeconds(getGlobalElementTimeOut())); } } From 9c3ad061d0574c8fd47fc43dabab9f9105f34c69 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 7 Mar 2023 17:22:02 +0530 Subject: [PATCH 04/41] Made changes wrt to appium java client 8 --- .../mobile/ios/IosMobileAutomationServer.java | 6 ++++-- automator/pom.xml | 18 ++++++++++++++++++ .../actions/mobile/MobileElementAction.java | 3 ++- .../mobile/ios/generic/HideKeyboardAction.java | 3 ++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java index 56f555ab8..39df343cf 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java @@ -15,6 +15,7 @@ import com.testsigma.agent.mobile.MobileAutomationServerService; import com.testsigma.agent.mobile.DeviceContainer; import com.testsigma.agent.mobile.MobileDevice; +import io.appium.java_client.AppiumDriver; import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.remote.MobileCapabilityType; import lombok.RequiredArgsConstructor; @@ -58,8 +59,9 @@ public void createSession(String uniqueId) throws MobileAutomationServerSessionE desiredCapabilities.setCapability("xcodeOrgId", "6F4CKCA4LX"); desiredCapabilities.setCapability("xcodeSigningId", "iPhone Developer"); desiredCapabilities.setCapability("app", "/Users/vikram/ios-apps/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app"); - device.setRemoteWebDriver(new IOSDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), - desiredCapabilities)); +// device.setRemoteWebDriver(new IOSDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), +// desiredCapabilities)); + device.setRemoteWebDriver(new AppiumDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()),desiredCapabilities)); } catch (Exception e) { throw new MobileAutomationServerSessionException(e.getMessage()); } diff --git a/automator/pom.xml b/automator/pom.xml index b3adc034d..d7e442c39 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -322,6 +322,24 @@ 5.3.20 compile + + org.springframework + spring-context + 5.3.20 + compile + + + org.springframework + spring-context + 5.3.20 + compile + + + org.springframework + spring-context + 5.3.20 + compile + diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java index b37281b3c..0c68b1e9b 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java @@ -14,6 +14,7 @@ import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.ElementAction; import com.testsigma.automator.actions.FindByType; +import io.appium.java_client.AppiumBy; import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileBy; import io.appium.java_client.NoSuchContextException; @@ -50,7 +51,7 @@ protected void findElement(String elementActionVariableName) throws Exception { AppiumDriver driver = getDriver(); if (this.getElementSearchCriteria().getFindByType().equals(FindByType.ACCESSIBILITY_ID)) { // elements = driver.findElementsByAccessibilityId(getElementSearchCriteria().getByValue()); - elements = driver.findElements(MobileBy.AccessibilityId(getElementSearchCriteria().getByValue())); + elements = driver.findElements(AppiumBy.ByAccessibilityId.accessibilityId(getElementSearchCriteria().getByValue())); } else { elements = ((WebDriver) driver).findElements(getElementSearchCriteria().getBy()); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 4a8b04dea..1ee8a3fd9 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -1,6 +1,7 @@ package com.testsigma.automator.actions.mobile.ios.generic; import com.testsigma.automator.actions.mobile.MobileElementAction; +import io.appium.java_client.AppiumBy; import io.appium.java_client.MobileBy; import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; @@ -106,7 +107,7 @@ private void clickOnReturnKeys() { private void clickOnHideKeyBoardAccessibilityID() { log.info("Using Hide Keyboard accessibilityId to hide keyboard"); try { - getDriver().findElement(MobileBy.AccessibilityId("Hide keyboard")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId("Hide keyboard")).click(); log.info("Using Hide Keyboard accessibilityId to hide keyboard didn't throw any exception"); } catch (Exception e) { log.error("**Tried to hide keyboard using Hide Keyboard id***", e); From defc58f5f8fab1bc8cb214f27d09bec75e9236be Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 14 Mar 2023 13:56:19 +0530 Subject: [PATCH 05/41] (feat): dependency updates --- agent-launcher/dependency-reduced-pom.xml | 2 +- agent-launcher/pom.xml | 2 +- agent/pom.xml | 8 ++++++++ automator/pom.xml | 8 +++++++- .../com/testsigma/automator/drivers/web/ChromeDriver.java | 4 ++++ server/pom.xml | 2 +- .../java/com/testsigma/service/TestDeviceService.java | 1 - 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/agent-launcher/dependency-reduced-pom.xml b/agent-launcher/dependency-reduced-pom.xml index 8b40abc9b..a5509f436 100644 --- a/agent-launcher/dependency-reduced-pom.xml +++ b/agent-launcher/dependency-reduced-pom.xml @@ -57,7 +57,7 @@ - 1.18.10 + 1.18.22 3.17 3.8.1 UTF-8 diff --git a/agent-launcher/pom.xml b/agent-launcher/pom.xml index e555dd1c6..4f3ec036a 100644 --- a/agent-launcher/pom.xml +++ b/agent-launcher/pom.xml @@ -13,7 +13,7 @@ 3.8.1 3.4 3.17 - 1.18.10 + 1.18.22 4.5.13 diff --git a/agent/pom.xml b/agent/pom.xml index f9846882b..161e21a5d 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -20,6 +20,8 @@ 11 11 3.8.1 + 4.8.1 + 31.1-jre 1.18.20 1.4.2.Final 1.11.46 @@ -139,6 +141,12 @@ com.android.tools.ddms ddmlib ${android.tools.version} + + + com.google.guava + guava + + diff --git a/automator/pom.xml b/automator/pom.xml index d7e442c39..89f6ac372 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -139,6 +139,12 @@ org.everit.json org.everit.json.schema ${org.everit.json.schema} + + + com.google.guava + guava + + @@ -284,7 +290,7 @@ com.testsigma testsigma-java-sdk - 1.0.0.rc1 + 1.0.10_beta_1 diff --git a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java index 57ea3fec8..020946fa3 100644 --- a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java @@ -27,6 +27,8 @@ public class ChromeDriver extends WebDriver { public ChromeDriver() { super(); chromeOptions = new ChromeOptions(); + chromeOptions.addArguments("--remote-allow-origins=*"); + } @Override @@ -34,6 +36,8 @@ protected void createDriverInstance(DesiredCapabilities desiredCapabilities) thr if (remoteServerURL != null) { remoteWebDriver = new RemoteWebDriver(remoteServerURL, chromeOptions.merge(desiredCapabilities)); } else { + System.out.println("test---" + desiredCapabilities.toString()); + System.out.println(chromeOptions.toString()); remoteWebDriver = new org.openqa.selenium.chrome.ChromeDriver(chromeOptions.merge(desiredCapabilities)); } } diff --git a/server/pom.xml b/server/pom.xml index 4b590aa23..d64c810d8 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -46,7 +46,7 @@ 7.11.0 1.18.20 1.4.2.Final - 31.0.1-jre + 31.1-jre 2.4.0 2.5.2 3.15 diff --git a/server/src/main/java/com/testsigma/service/TestDeviceService.java b/server/src/main/java/com/testsigma/service/TestDeviceService.java index 31ba7674d..b3c7bd6bd 100644 --- a/server/src/main/java/com/testsigma/service/TestDeviceService.java +++ b/server/src/main/java/com/testsigma/service/TestDeviceService.java @@ -34,7 +34,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; -import org.testng.reporters.jq.TestPanel; import java.io.IOException; import java.sql.Timestamp; From a234597c2118635950f4ac006299fafdf7789a39 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 14 Mar 2023 16:03:36 +0530 Subject: [PATCH 06/41] fix merging capabailities https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/#merging-capabilities-is-no-longer-changing-the-calling-object --- .../com/testsigma/automator/drivers/web/ChromeDriver.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java index 020946fa3..89963c764 100644 --- a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java @@ -36,9 +36,8 @@ protected void createDriverInstance(DesiredCapabilities desiredCapabilities) thr if (remoteServerURL != null) { remoteWebDriver = new RemoteWebDriver(remoteServerURL, chromeOptions.merge(desiredCapabilities)); } else { - System.out.println("test---" + desiredCapabilities.toString()); - System.out.println(chromeOptions.toString()); - remoteWebDriver = new org.openqa.selenium.chrome.ChromeDriver(chromeOptions.merge(desiredCapabilities)); + chromeOptions = chromeOptions.merge(desiredCapabilities); + remoteWebDriver = new org.openqa.selenium.chrome.ChromeDriver(chromeOptions); } } From 7ad4771bbf9d143d5683d707c47d3d9740b2f5d1 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 21 Mar 2023 16:14:44 +0530 Subject: [PATCH 07/41] (feat): selenium fixes --- .../main/java/com/testsigma/agent/TestsigmaAgent.java | 1 + automator/pom.xml | 6 ++++++ .../com/testsigma/automator/actions/DriverAction.java | 2 +- .../com/testsigma/automator/drivers/TestsigmaDriver.java | 5 +++-- .../testsigma/automator/drivers/WebDriverManager.java | 2 +- .../testsigma/automator/drivers/web/ChromeDriver.java | 9 ++++++--- .../service/TestsigmaLabDriverSettingsService.java | 2 +- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/TestsigmaAgent.java b/agent/src/main/java/com/testsigma/agent/TestsigmaAgent.java index 871607d17..234e89383 100644 --- a/agent/src/main/java/com/testsigma/agent/TestsigmaAgent.java +++ b/agent/src/main/java/com/testsigma/agent/TestsigmaAgent.java @@ -24,6 +24,7 @@ @Log4j2 public class TestsigmaAgent { public static void main(String[] args) { + System.setProperty("webdriver.http.factory", "jdk-http-client"); String wrapperPort = System.getProperty("agent.wrapper.port"); if (StringUtils.isNotBlank(wrapperPort)) { WrapperConnector.getInstance().disconnectHook(); diff --git a/automator/pom.xml b/automator/pom.xml index 89f6ac372..8ca516053 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -83,6 +83,12 @@ + + org.seleniumhq.selenium + selenium-http-jdk-client + ${selenium.version} + + org.springframework diff --git a/automator/src/com/testsigma/automator/actions/DriverAction.java b/automator/src/com/testsigma/automator/actions/DriverAction.java index 55daa47d9..3e1258546 100644 --- a/automator/src/com/testsigma/automator/actions/DriverAction.java +++ b/automator/src/com/testsigma/automator/actions/DriverAction.java @@ -50,7 +50,7 @@ protected void afterExecute() throws AutomatorException { private void setImplicitTimeout() { if (getGlobalElementTimeOut() != null && !getTimeout().equals(getGlobalElementTimeOut())) { - log.info("Updating implicit timeout to step level timeout:" + getTimeout()); + log.info("Updating implicit timeout to step level timeout:" + getTimeout().getSeconds()); setDriverImplicitTimeout(getTimeout()); } } diff --git a/automator/src/com/testsigma/automator/drivers/TestsigmaDriver.java b/automator/src/com/testsigma/automator/drivers/TestsigmaDriver.java index fc18370d3..ac8b60375 100644 --- a/automator/src/com/testsigma/automator/drivers/TestsigmaDriver.java +++ b/automator/src/com/testsigma/automator/drivers/TestsigmaDriver.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -70,11 +71,11 @@ protected void setTestsigmaLabCapabilities() throws AutomatorException { protected void setTimeouts() throws AutomatorException { if (settings != null && settings.getElementTimeout() != null) { remoteWebDriver.manage().timeouts().implicitlyWait( - settings.getElementTimeout(), TimeUnit.SECONDS); + Duration.ofSeconds(settings.getElementTimeout())); } if (settings != null && settings.getPageLoadTimeout() != null) { remoteWebDriver.manage().timeouts().implicitlyWait( - settings.getPageLoadTimeout(), TimeUnit.SECONDS); + Duration.ofSeconds(settings.getPageLoadTimeout())); } } diff --git a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java index 96f189b26..e78fcb280 100644 --- a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java +++ b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java @@ -92,7 +92,7 @@ private void setWebSession(RemoteWebDriver driver) { TestDeviceSettings testDeviceSettings = EnvironmentRunner.getRunnerEnvironmentEntity().getEnvSettings(); String executionUuid = EnvironmentRunner.getRunnerExecutionId(); Capabilities cap = driver.getCapabilities(); - String browserVersion = cap.getBrowserVersion(); + String browserVersion = cap.getCapability("browserVersion").toString(); if (browserVersion.contains(".")) { browserVersion = browserVersion.substring(0, browserVersion.indexOf(".") + 2); diff --git a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java index 89963c764..d0aa6152a 100644 --- a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java @@ -27,16 +27,19 @@ public class ChromeDriver extends WebDriver { public ChromeDriver() { super(); chromeOptions = new ChromeOptions(); - chromeOptions.addArguments("--remote-allow-origins=*"); - } @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { if (remoteServerURL != null) { - remoteWebDriver = new RemoteWebDriver(remoteServerURL, chromeOptions.merge(desiredCapabilities)); + chromeOptions = chromeOptions.addArguments("--remote-allow-origins=*"); + chromeOptions = chromeOptions.merge(desiredCapabilities); + log.info("chromeOptions::: " + chromeOptions); + remoteWebDriver = new RemoteWebDriver(remoteServerURL, chromeOptions); } else { + chromeOptions = chromeOptions.addArguments("--remote-allow-origins=*"); chromeOptions = chromeOptions.merge(desiredCapabilities); + log.info("chromeOptions::: " + chromeOptions); remoteWebDriver = new org.openqa.selenium.chrome.ChromeDriver(chromeOptions); } } diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index dbc823277..a3004ab8f 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -119,7 +119,7 @@ public void setWebCapabilities(TestDevice testDevice, Float.parseFloat(platformBrowserVersion.getDisplayVersion()) > 12) { capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "3.4.0")); } else { - capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "3.8.1")); + capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "4.8.1")); } String resolution = platformScreenResolution.getResolution(); if (!StringUtils.isBlank(resolution)) { From 2ab5966a09af238602af0bbb0097d8933bdfae9f Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Wed, 5 Apr 2023 13:13:37 +0530 Subject: [PATCH 08/41] feat: selenium 4 latest dependency --- agent/pom.xml | 2 +- automator/pom.xml | 4 ++-- .../com/testsigma/automator/constants/TSCapabilityType.java | 2 +- server/pom.xml | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent/pom.xml b/agent/pom.xml index 161e21a5d..2639127b1 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -20,7 +20,7 @@ 11 11 3.8.1 - 4.8.1 + 4.8.2 31.1-jre 1.18.20 1.4.2.Final diff --git a/automator/pom.xml b/automator/pom.xml index 8ca516053..3a849914d 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -16,7 +16,7 @@ 1.5.0 2.2.0 2.8.5 - 4.8.1 + 4.8.2 8.3.0 9.4.12.v20180830 4.4 @@ -296,7 +296,7 @@ com.testsigma testsigma-java-sdk - 1.0.10_beta_1 + 1.2.0_beta_1 diff --git a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java index 153f74e41..4876365d9 100644 --- a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java +++ b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java @@ -10,7 +10,7 @@ public interface TSCapabilityType extends CapabilityType { String OS = "os"; String BUNDLE_ID = "bundleId"; String SELENIUM_VERSION = "seleniumVersion"; - String ACCEPT_SSL_CERTS = "acceptSslCerts"; + String ACCEPT_SSL_CERTS = "acceptInsecurecerts"; String UNHANDLED_PROMPT_BEHAVIOUR_KEY = "unhandledPromptBehavior"; String UNHANDLED_PROMPT_BEHAVIOUR_VALUE = "ignore"; String AVOID_PROXY = "avoidProxy"; diff --git a/server/pom.xml b/server/pom.xml index d64c810d8..428858de2 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -30,6 +30,7 @@ UTF-8 11 3.8.1 + 4.8.2 2.11.4 20160810 0.2 From 61195a33fa9d762ab670c7d59e636ce4a9a0fd36 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Wed, 5 Apr 2023 15:18:35 +0530 Subject: [PATCH 09/41] selenium 4 minor changes --- .../actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java | 2 +- .../src/com/testsigma/automator/drivers/WebDriverManager.java | 2 +- .../testsigma/service/TestsigmaLabDriverSettingsService.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java index adcdb09dc..5d347c486 100644 --- a/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java +++ b/automator/src/com/testsigma/automator/actions/web/wait/WaitUntilFileDownloadIsCompleteAction.java @@ -33,7 +33,7 @@ public void execute() throws Exception { " return progress_lst"; //We create a custom wait with long sleep time. Since we are only allowing max of 120 secs for step level timeout(which // may not be sufficient for some downloads), we will be giving additional timeout here. - WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(600), Duration.ofSeconds(5000)); + WebDriverWait waiter = new WebDriverWait(getDriver(), Duration.ofSeconds(600), Duration.ofMillis(5000)); boolean isDownloadComplted = waiter.until(CustomExpectedConditions.downloadToBeCompletedInChrome(chromeJavaScript)); Assert.isTrue(isDownloadComplted, String.format(FAILURE_MESSAGE, 600)); diff --git a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java index e78fcb280..96f189b26 100644 --- a/automator/src/com/testsigma/automator/drivers/WebDriverManager.java +++ b/automator/src/com/testsigma/automator/drivers/WebDriverManager.java @@ -92,7 +92,7 @@ private void setWebSession(RemoteWebDriver driver) { TestDeviceSettings testDeviceSettings = EnvironmentRunner.getRunnerEnvironmentEntity().getEnvSettings(); String executionUuid = EnvironmentRunner.getRunnerExecutionId(); Capabilities cap = driver.getCapabilities(); - String browserVersion = cap.getCapability("browserVersion").toString(); + String browserVersion = cap.getBrowserVersion(); if (browserVersion.contains(".")) { browserVersion = browserVersion.substring(0, browserVersion.indexOf(".") + 2); diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index a3004ab8f..7a492021f 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -119,7 +119,7 @@ public void setWebCapabilities(TestDevice testDevice, Float.parseFloat(platformBrowserVersion.getDisplayVersion()) > 12) { capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "3.4.0")); } else { - capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "4.8.1")); + capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "4.8.2")); } String resolution = platformScreenResolution.getResolution(); if (!StringUtils.isBlank(resolution)) { From 6482009a8a8029739b222a5e9124404f1d85902b Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 24 Apr 2023 21:43:30 +0530 Subject: [PATCH 10/41] TRD-217 Tested and made changes as per Appium 2 and appium java client 8.3.0 --- .../agent/mobile/MobileAutomationServer.java | 13 +++++++++++- .../AndroidMobileAutomationServer.java | 5 ++--- .../mobile/ios/IosMobileAutomationServer.java | 5 ++--- .../com/testsigma/agent/utils/PathUtil.java | 4 ++++ .../actions/mobile/MobileDriverAction.java | 13 ++++-------- .../actions/mobile/MobileElementAction.java | 2 -- ...obileNativeOrientationPortraitSnippet.java | 2 +- .../MobileNativeSwipeElementProxyAction.java | 1 + .../press/MobileWebPressBackSpaceAction.java | 2 +- .../press/MobileWebPressSpaceAction.java | 2 +- .../mobile/press/PressBackSpaceSnippet.java | 2 +- .../mobile/press/PressEnterSnippet.java | 20 ++----------------- .../actions/mobile/press/PressKeySnippet.java | 3 +-- .../mobile/press/PressSpaceSnippet.java | 2 +- .../MobileNativeSwipeElementProxyAction.java | 1 + .../VerifyOrientationIsLandscapeSnippet.java | 2 +- .../VerifyOrientationIsPortraitSnippet.java | 2 +- .../drivers/mobile/AndroidWebDriver.java | 1 + .../drivers/mobile/IosWebDriver.java | 1 + 19 files changed, 38 insertions(+), 45 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java index f10afdaff..03b473611 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java @@ -12,6 +12,9 @@ import com.testsigma.agent.utils.NetworkUtil; import com.testsigma.agent.utils.PathUtil; +import io.appium.java_client.service.local.AppiumDriverLocalService; +import io.appium.java_client.service.local.AppiumServiceBuilder; +import io.appium.java_client.service.local.flags.GeneralServerFlag; import lombok.Getter; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.SystemUtils; @@ -29,6 +32,8 @@ public class MobileAutomationServer { private Process mobileAutomationServerProcess; private File androidHome; private File jreHome; + + private File appiumHome; private File mobileAutomationServerExecutablePath; private File logFilePath; private String serverIpAddress; @@ -46,6 +51,10 @@ private File jreHome() { return new File(PathUtil.getInstance().getJrePath()); } + private File appiumHome(){ + return new File(PathUtil.getInstance().getMobileAutomationDriverPath()); + } + private String serverIP() { String address = "127.0.0.1"; try { @@ -64,6 +73,7 @@ public void start() { } this.androidHome = androidHome(); this.jreHome = jreHome(); + this.appiumHome = appiumHome(); this.mobileAutomationServerExecutablePath = new File(PathUtil.getInstance().getMobileAutomationServerPath(), "appium"); if (SystemUtils.IS_OS_WINDOWS) { this.mobileAutomationServerExecutablePath = new File(PathUtil.getInstance().getMobileAutomationServerPath(), "appium.exe"); @@ -71,7 +81,7 @@ public void start() { this.serverIpAddress = serverIP(); this.logFilePath = new File(PathUtil.getInstance().getLogsPath() + File.separator + "appium.log"); Integer serverPort = NetworkUtil.getFreePort(); - this.serverURL = String.format("http://%s:%d/wd/hub", serverIpAddress, serverPort); + this.serverURL = String.format("http://%s:%d", serverIpAddress, serverPort); log.info("Starting Mobile Automation Server at - " + serverURL); @@ -87,6 +97,7 @@ public void start() { "--log-timestamp", "--allow-insecure", "chromedriver_autodownload"); processBuilder.directory(new File(PathUtil.getInstance().getMobileAutomationServerPath())); + processBuilder.environment().put("APPIUM_HOME", appiumHome.getAbsolutePath()); processBuilder.environment().put("ANDROID_HOME", androidHome.getAbsolutePath()); processBuilder.environment().put("JAVA_HOME", jreHome.getAbsolutePath()); processBuilder.redirectErrorStream(true); diff --git a/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java index 9f0a03e42..7fafcfda1 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java @@ -27,8 +27,8 @@ public class AndroidMobileAutomationServer { private final DeviceContainer deviceContainer; private final CommandExecutor commandExecutor; - private final String UI_AUTOMATOR2_SERVER_TEST_APK = "appium-uiautomator2-server-test.apk"; - private final String UI_AUTOMATOR2_SERVER_APK = "appium-uiautomator2-server.apk"; + private final String UI_AUTOMATOR2_SERVER_TEST_APK = "appium-uiautomator2-server-debug-androidTest.apk"; + private final String UI_AUTOMATOR2_SERVER_APK = "appium-uiautomator2-server-v5.8.0.apk"; private final String APPIUM_SETTINGS_APK = "settings_apk-debug.apk"; private final String UI_AUTOMATOR2_PACKAGE = "io.appium.uiautomator2.server"; private final String UI_AUTOMATOR2_TEST_PACKAGE = "io.appium.uiautomator2.server.test"; @@ -38,7 +38,6 @@ public void installDrivers(String uniqueId) throws MobileLibraryInstallException try { MobileDevice mobileDevice = deviceContainer.getDevice(uniqueId); IDevice device = mobileDevice.getIDevice(); - this.installAppiumSettings(device); this.startAppiumSettings(device); this.installUIAutomatorServer(device); diff --git a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java index 39df343cf..f67fb7cea 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java @@ -59,9 +59,8 @@ public void createSession(String uniqueId) throws MobileAutomationServerSessionE desiredCapabilities.setCapability("xcodeOrgId", "6F4CKCA4LX"); desiredCapabilities.setCapability("xcodeSigningId", "iPhone Developer"); desiredCapabilities.setCapability("app", "/Users/vikram/ios-apps/ios-test-app/build/Release-iphoneos/TestApp-iphoneos.app"); -// device.setRemoteWebDriver(new IOSDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), -// desiredCapabilities)); - device.setRemoteWebDriver(new AppiumDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()),desiredCapabilities)); + device.setRemoteWebDriver(new IOSDriver(new URL(mobileAutomationServerService.getMobileAutomationServer().getServerURL()), + desiredCapabilities)); } catch (Exception e) { throw new MobileAutomationServerSessionException(e.getMessage()); } diff --git a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java index 23aba1cb1..c9269d63a 100644 --- a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java +++ b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java @@ -38,6 +38,9 @@ public class PathUtil { private String iosPath = null; @Getter private String mobileAutomationServerPath = null; + + @Getter + private String mobileAutomationDriverPath = null; @Getter private String upgradePath = null; @Getter @@ -79,6 +82,7 @@ public void setPathsFromContext(boolean reset) { driversPath = rootPath + File.separator + "drivers"; jrePath = rootPath + File.separator + "jre"; mobileAutomationServerPath = rootPath + File.separator + "appium"; + mobileAutomationDriverPath = mobileAutomationServerPath + "/drivers"; androidPath = rootPath + File.separator + "android"; iosPath = rootPath + File.separator + "ios"; diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java index 0336e0e87..29a603b87 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java @@ -9,24 +9,19 @@ package com.testsigma.automator.actions.mobile; -import com.google.common.collect.ImmutableMap; + import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.DriverAction; import io.appium.java_client.AppiumDriver; -import io.appium.java_client.NoSuchContextException; + import io.appium.java_client.remote.MobileCapabilityType; import lombok.extern.log4j.Log4j2; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebDriverException; + import org.openqa.selenium.remote.Command; -import org.openqa.selenium.remote.DriverCommand; + import org.openqa.selenium.remote.Response; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import static com.google.common.base.Preconditions.checkNotNull; @Log4j2 public abstract class MobileDriverAction extends DriverAction { diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java index 0c68b1e9b..0dbd27ad2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileElementAction.java @@ -50,7 +50,6 @@ protected void findElement(String elementActionVariableName) throws Exception { setElementSearchCriteria(elementActionVariableName); AppiumDriver driver = getDriver(); if (this.getElementSearchCriteria().getFindByType().equals(FindByType.ACCESSIBILITY_ID)) { -// elements = driver.findElementsByAccessibilityId(getElementSearchCriteria().getByValue()); elements = driver.findElements(AppiumBy.ByAccessibilityId.accessibilityId(getElementSearchCriteria().getByValue())); } else { elements = ((WebDriver) driver).findElements(getElementSearchCriteria().getBy()); @@ -100,7 +99,6 @@ protected void handleStaleelementExecptionOnClickAction() throws Exception { } public void tapByElementCoOrdinates(WebElement webElement, AppiumDriver driver) throws Exception { - Point loc = webElement.getLocation(); Point center = getCenter(webElement); int x = center.getX(); int y = center.getY(); diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java index 1397daa3c..e5b5b22c0 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileNativeOrientationPortraitSnippet.java @@ -22,7 +22,7 @@ public class MobileNativeOrientationPortraitSnippet extends MobileElementAction @Override public void execute() throws Exception { getDriver().execute(DriverCommand.SET_SCREEN_ORIENTATION, - ImmutableMap.of("orientation", ScreenOrientation.LANDSCAPE.value().toUpperCase())); + ImmutableMap.of("orientation", ScreenOrientation.PORTRAIT.value().toUpperCase())); setSuccessMessage(SUCCESS_MESSAGE); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/swipe/MobileNativeSwipeElementProxyAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/swipe/MobileNativeSwipeElementProxyAction.java index de59232cf..911f7cbc4 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/swipe/MobileNativeSwipeElementProxyAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/swipe/MobileNativeSwipeElementProxyAction.java @@ -110,6 +110,7 @@ public void execute() throws Exception { MobileNativeSwipeMiddleToBottomAction middleToBottom = (MobileNativeSwipeMiddleToBottomAction) this.initializeChildSnippet(MobileNativeSwipeMiddleToBottomAction.class); middleToBottom.execute(); this.setSuccessMessage(middleToBottom.getSuccessMessage()); + break; default: setErrorMessage("Unable to Perform Swipe Action due to error at swipe direction"); throw new AutomatorException("Unable to Perform Swipe Action due to error at swipe direction"); diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java index e40462cbe..1fb6404e0 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressBackSpaceAction.java @@ -32,7 +32,7 @@ public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.DEL)); } else { - getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId("delete")).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java index 822fe9739..e6cd980c7 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/press/MobileWebPressSpaceAction.java @@ -28,7 +28,7 @@ public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.SPACE)); } else { - getDriver().findElement(AppiumBy.accessibilityId("space")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId("space")).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java index dd0847c6b..020a93201 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressBackSpaceSnippet.java @@ -30,7 +30,7 @@ public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.DEL)); } else { - getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId("delete")).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java index b526064a2..e185dbe60 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressEnterSnippet.java @@ -14,6 +14,7 @@ import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.nativekey.AndroidKey; import io.appium.java_client.android.nativekey.KeyEvent; +import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.By; import org.openqa.selenium.InvalidElementStateException; @@ -32,28 +33,11 @@ public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.ENTER)); } else { - getDriver().findElement(AppiumBy.accessibilityId("Done")).click(); + getDriver().switchTo().activeElement().sendKeys(Keys.RETURN); } setSuccessMessage(SUCCESS_MESSAGE); } - private void clickOnReturnKeys() { - - List.of("Return", "return", "done", "Done", "search", "Search", "Next", "next", "Go", "go").forEach(button -> { - try { - getDriver().findElement(By.xpath("//*[contains(@name, '" + button + "')]")).click(); - } catch (Exception e) { - log.error(e, e); - } - try { - getDriver().findElement(By.name(button)); - } catch (Exception e) { - log.error(e, e); - } - } - ); - } - @Override protected void handleException(Exception e) { super.handleException(e); diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java index 7a6806418..989638a1a 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressKeySnippet.java @@ -27,11 +27,10 @@ public class PressKeySnippet extends MobileElementAction { @Override public void execute() throws Exception { -// getDriver().getKeyboard().pressKey(Keys.valueOf(getTestData().toUpperCase())); if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.valueOf(getTestData().toUpperCase()))); } else { - getDriver().findElement(AppiumBy.accessibilityId("delete")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId(getTestData().toUpperCase())).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java index 396eaf650..0a0a7b808 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/PressSpaceSnippet.java @@ -29,7 +29,7 @@ public void execute() throws Exception { if (getDriver() instanceof AndroidDriver) { ((AndroidDriver) getDriver()).pressKey(new KeyEvent(AndroidKey.SPACE)); } else { - getDriver().findElement(AppiumBy.accessibilityId("space")).click(); + getDriver().findElement(AppiumBy.ByAccessibilityId.accessibilityId(("space"))).click(); } setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementProxyAction.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementProxyAction.java index 40608ae08..f990b3701 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementProxyAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementProxyAction.java @@ -112,6 +112,7 @@ public void execute() throws Exception { MobileNativeSwipeMiddleToBottomSnippet middleToBottom = (MobileNativeSwipeMiddleToBottomSnippet) this.initializeChildSnippet(MobileNativeSwipeMiddleToBottomSnippet.class); middleToBottom.execute(); this.setSuccessMessage(middleToBottom.getSuccessMessage()); + break; default: setErrorMessage("Unable to Perform Swipe Action due to error at swipe direction"); throw new AutomatorException("Unable to Perform Swipe Action due to error at swipe direction"); diff --git a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java index d28d73b86..a2b1c15fd 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsLandscapeSnippet.java @@ -25,7 +25,7 @@ public class VerifyOrientationIsLandscapeSnippet extends MobileDriverAction { @Override public void execute() throws Exception { - String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).toString(); + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString(); Assert.isTrue(orientation.equalsIgnoreCase(String.valueOf(ScreenOrientation.LANDSCAPE)), String.format(SCREEN_NOT_LANDSCAPE, orientation)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java index 88e2e8b6b..d86adb460 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/verify/VerifyOrientationIsPortraitSnippet.java @@ -24,7 +24,7 @@ public class VerifyOrientationIsPortraitSnippet extends MobileDriverAction { @Override public void execute() throws Exception { - String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).toString(); + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString(); Assert.isTrue(orientation.equalsIgnoreCase(ScreenOrientation.PORTRAIT.toString()), String.format(SCREEN_NOT_PORTRAIT, orientation)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java index f26983f5c..06470e9e0 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/AndroidWebDriver.java @@ -33,6 +33,7 @@ protected void setHybridCapabilities() throws AutomatorException, MalformedURLEx settings.getChromedriverExecutableDir())); } capabilities.add(new WebDriverCapability(ChromeOptions.CAPABILITY, options)); + capabilities.add(new WebDriverCapability("automationName","uiAutomator2")); capabilities.add(new WebDriverCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, Boolean.TRUE)); capabilities.add(new WebDriverCapability(AndroidMobileCapabilityType.RESET_KEYBOARD, Boolean.TRUE)); } diff --git a/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java index 4904b7a02..e5543f05c 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/IosWebDriver.java @@ -23,6 +23,7 @@ public IosWebDriver() { @Override protected void setCommonCapabilities() throws AutomatorException { super.setCommonCapabilities(); + capabilities.add(new WebDriverCapability("automationName","XCUITest")); capabilities.add(new WebDriverCapability(MobileCapabilityType.PLATFORM_NAME, Platform.iOS.name())); } From ee2306941fcefbe64f1a399d225fbcd209246220 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Wed, 26 Apr 2023 12:12:43 +0530 Subject: [PATCH 11/41] feat(Se4): fixes --- agent/pom.xml | 2 +- .../src/com/testsigma/automator/constants/TSCapabilityType.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/pom.xml b/agent/pom.xml index 2639127b1..7aea4129a 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -22,7 +22,7 @@ 3.8.1 4.8.2 31.1-jre - 1.18.20 + 1.18.22 1.4.2.Final 1.11.46 25.3.0 diff --git a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java index 4876365d9..153f74e41 100644 --- a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java +++ b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java @@ -10,7 +10,7 @@ public interface TSCapabilityType extends CapabilityType { String OS = "os"; String BUNDLE_ID = "bundleId"; String SELENIUM_VERSION = "seleniumVersion"; - String ACCEPT_SSL_CERTS = "acceptInsecurecerts"; + String ACCEPT_SSL_CERTS = "acceptSslCerts"; String UNHANDLED_PROMPT_BEHAVIOUR_KEY = "unhandledPromptBehavior"; String UNHANDLED_PROMPT_BEHAVIOUR_VALUE = "ignore"; String AVOID_PROXY = "avoidProxy"; From 99552e178e46e5de2cc21d4162c866355e412bac Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 2 May 2023 17:14:50 +0530 Subject: [PATCH 12/41] TRD-217 Addressing review comments --- automator/pom.xml | 36 ------------------- .../ChangeScreenOrientationAction.java | 7 ++-- .../ChangeScreenOrientationAction.java | 5 ++- .../schedules-calendar.component.ts | 2 +- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/automator/pom.xml b/automator/pom.xml index 3a849914d..6c182152e 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -316,42 +316,6 @@ 5.3.20 compile - - org.springframework - spring-context - 5.3.20 - compile - - - org.springframework - spring-context - 5.3.20 - compile - - - org.springframework - spring-context - 5.3.20 - compile - - - org.springframework - spring-context - 5.3.20 - compile - - - org.springframework - spring-context - 5.3.20 - compile - - - org.springframework - spring-context - 5.3.20 - compile - diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java index cd2d4c83b..242079671 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java @@ -8,11 +8,14 @@ public class ChangeScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.ChangeScreenOrientationAction { public void changeOrientation() { - if (getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString().equalsIgnoreCase(ScreenOrientation.LANDSCAPE.value())) { + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString(); + if (ScreenOrientation.LANDSCAPE.value().equalsIgnoreCase(orientation)) { changeToPortrait(); + } else if (ScreenOrientation.PORTRAIT.value().equalsIgnoreCase(orientation)){ + changeToLandscape(); } else { changeToLandscape(); - } + } } public void changeToPortrait() { diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java index 38134c3d7..9dae5e0b7 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/ChangeScreenOrientationAction.java @@ -7,8 +7,11 @@ public class ChangeScreenOrientationAction extends com.testsigma.automator.actions.mobile.generic.ChangeScreenOrientationAction { public void changeOrientation() { - if (getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString().equalsIgnoreCase(ScreenOrientation.LANDSCAPE.value())) { + String orientation = getDriver().execute(DriverCommand.GET_SCREEN_ORIENTATION).getValue().toString(); + if (ScreenOrientation.LANDSCAPE.value().equalsIgnoreCase(orientation)) { changeToPortrait(); + } else if (ScreenOrientation.PORTRAIT.value().equalsIgnoreCase(orientation)){ + changeToLandscape(); } else { changeToLandscape(); } diff --git a/ui/src/app/components/webcomponents/schedules-calendar.component.ts b/ui/src/app/components/webcomponents/schedules-calendar.component.ts index dc59a7efc..d07d0d43c 100644 --- a/ui/src/app/components/webcomponents/schedules-calendar.component.ts +++ b/ui/src/app/components/webcomponents/schedules-calendar.component.ts @@ -1,7 +1,7 @@ import {ChangeDetectorRef, Component, Input, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core'; import {SchedulePlanService} from "../../services/schedule-plan.service"; import {CalendarEvent, CalendarMonthViewBeforeRenderEvent, CalendarWeekViewBeforeRenderEvent} from 'angular-calendar'; -import RRule from 'rrule'; +import {RRule} from 'rrule'; import {ViewPeriod} from 'calendar-utils'; import {Page} from "../../shared/models/page"; import {SchedulePlan} from "../../models/schedule-plan.model"; From 19eab55a84781b570e62dc94c5ebd22cc0c13458 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Wed, 3 May 2023 15:02:18 +0530 Subject: [PATCH 13/41] fix(se4): remove hardcoded desired capability --- .../com/testsigma/automator/drivers/web/ChromeDriver.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java index d0aa6152a..52edc26a6 100644 --- a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java @@ -31,15 +31,11 @@ public ChromeDriver() { @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { + chromeOptions = chromeOptions.merge(desiredCapabilities); + log.info("chromeOptions::: " + chromeOptions); if (remoteServerURL != null) { - chromeOptions = chromeOptions.addArguments("--remote-allow-origins=*"); - chromeOptions = chromeOptions.merge(desiredCapabilities); - log.info("chromeOptions::: " + chromeOptions); remoteWebDriver = new RemoteWebDriver(remoteServerURL, chromeOptions); } else { - chromeOptions = chromeOptions.addArguments("--remote-allow-origins=*"); - chromeOptions = chromeOptions.merge(desiredCapabilities); - log.info("chromeOptions::: " + chromeOptions); remoteWebDriver = new org.openqa.selenium.chrome.ChromeDriver(chromeOptions); } } From c06fd9768dc2c720962bd29356e21fceb7f146b4 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Thu, 4 May 2023 18:56:46 +0530 Subject: [PATCH 14/41] fix(se4): address review comment --- .../service/TestsigmaLabDriverSettingsService.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index 7a492021f..eac27a790 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -114,13 +114,6 @@ public void setWebCapabilities(TestDevice testDevice, capabilities.add(new WebDriverCapability(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion())); capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION, platformBrowserVersion.getVersion())); - Browsers browser = platformBrowserVersion.getName(); - if (browser.equals(Browsers.Safari) && - Float.parseFloat(platformBrowserVersion.getDisplayVersion()) > 12) { - capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "3.4.0")); - } else { - capabilities.add(new WebDriverCapability(TSCapabilityType.SELENIUM_VERSION, "4.8.2")); - } String resolution = platformScreenResolution.getResolution(); if (!StringUtils.isBlank(resolution)) { capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, resolution)); From 09f1b459afa28f0480f079c0ce284bff7e530cbe Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 8 May 2023 17:59:34 +0530 Subject: [PATCH 15/41] TRD-217 Upgraded Agent version --- agent/src/main/resources/agent.properties | 2 +- server/src/main/java/com/testsigma/dto/AgentDTO.java | 2 +- server/src/main/resources/application.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/src/main/resources/agent.properties b/agent/src/main/resources/agent.properties index b5be3d99f..ae678138f 100644 --- a/agent/src/main/resources/agent.properties +++ b/agent/src/main/resources/agent.properties @@ -9,4 +9,4 @@ cloud.url=${CLOUD_URL:https://local.testsigmaos.com} local.server.url=${LOCAL_SERVER_URL:http://localhost:9090} local.agent.register=${LOCAL_AGENT_REGISTER:true} -agent.version=2.9.1 +agent.version=2.9.2 diff --git a/server/src/main/java/com/testsigma/dto/AgentDTO.java b/server/src/main/java/com/testsigma/dto/AgentDTO.java index 9161134de..35252f727 100644 --- a/server/src/main/java/com/testsigma/dto/AgentDTO.java +++ b/server/src/main/java/com/testsigma/dto/AgentDTO.java @@ -30,5 +30,5 @@ public class AgentDTO { private String hostName; private AgentOs osType; private String osVersion; - private String currentAgentVersion = "2.9.1"; + private String currentAgentVersion = "2.9.2"; } diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index e401dea95..1591668b5 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -1,6 +1,6 @@ server.port=${TESTSIGMA_SERVER_PORT:9090} server.url=${TESTSIGMA_SERVER_URL:https://local.testsigmaos.com} -server.version=v2.9.1 +server.version=v2.9.2 server.local.url=${TESTSIGMA_SERVER_LOCAL_URL:http://localhost:${server.port}} local.agent.url=${LOCAL_AGENT_URL:http://localhost:9393/agent} local.agent.download.tag=latest From 083eb0ac4032e3da1241faeec2056f6f0f0a14c9 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 8 May 2023 18:13:47 +0530 Subject: [PATCH 16/41] TRD-217 Changed uiautomator2 apk file version --- .../agent/mobile/android/AndroidMobileAutomationServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java index 7fafcfda1..d3544888c 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/android/AndroidMobileAutomationServer.java @@ -28,7 +28,7 @@ public class AndroidMobileAutomationServer { private final CommandExecutor commandExecutor; private final String UI_AUTOMATOR2_SERVER_TEST_APK = "appium-uiautomator2-server-debug-androidTest.apk"; - private final String UI_AUTOMATOR2_SERVER_APK = "appium-uiautomator2-server-v5.8.0.apk"; + private final String UI_AUTOMATOR2_SERVER_APK = "appium-uiautomator2-server-v5.8.2.apk"; private final String APPIUM_SETTINGS_APK = "settings_apk-debug.apk"; private final String UI_AUTOMATOR2_PACKAGE = "io.appium.uiautomator2.server"; private final String UI_AUTOMATOR2_TEST_PACKAGE = "io.appium.uiautomator2.server.test"; From bec7769d9ce2d3153c4a33bf6657404defc83d8b Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 9 May 2023 14:20:47 +0530 Subject: [PATCH 17/41] TRD-217 Upgrading appium client version to 8.4.0 --- automator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automator/pom.xml b/automator/pom.xml index 6c182152e..50c27ed66 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -17,7 +17,7 @@ 2.2.0 2.8.5 4.8.2 - 8.3.0 + 8.4.0 9.4.12.v20180830 4.4 1.5.1 From 942ae334a825cbae82431b5bc44571ce1961dc16 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 16 May 2023 17:11:28 +0530 Subject: [PATCH 18/41] TRD-217 Handled changes related to capabilities --- automator/pom.xml | 2 +- .../actions/mobile/MobileDriverAction.java | 6 --- .../automator/actions/mobile/SwipeAction.java | 12 ++--- .../actions/mobile/TapPointAction.java | 12 ++--- .../ios/generic/HideKeyboardAction.java | 4 +- .../presskey/LongPressOnElementAction.java | 12 ++--- .../mobile/press/LongPressSnippet.java | 12 ++--- ...obileNativeSwipeBottomToMiddleSnippet.java | 12 ++--- .../MobileNativeSwipeBottomToTopSnippet.java | 12 ++--- ...bileNativeSwipeElementToBottomSnippet.java | 12 ++--- ...MobileNativeSwipeElementToLeftSnippet.java | 12 ++--- ...obileNativeSwipeElementToRightSnippet.java | 12 ++--- .../MobileNativeSwipeElementToTopSnippet.java | 12 ++--- .../MobileNativeSwipeLeftToMiddleSnippet.java | 12 ++--- .../MobileNativeSwipeLeftToRightSnippet.java | 12 ++--- ...obileNativeSwipeMiddleToBottomSnippet.java | 12 ++--- .../MobileNativeSwipeMiddleToLeftSnippet.java | 12 ++--- ...MobileNativeSwipeMiddleToRightSnippet.java | 12 ++--- .../MobileNativeSwipeMiddleToTopSnippet.java | 12 ++--- .../MobileNativeSwipeRightToLeftSnippet.java | 12 ++--- ...MobileNativeSwipeRightToMiddleSnippet.java | 12 ++--- .../MobileNativeSwipeTopToBottomSnippet.java | 12 ++--- .../MobileNativeSwipeTopToMiddleSnippet.java | 12 ++--- .../MobileNativeTapCoordinatesSnippet.java | 12 ++--- .../mobile/tap/MobileNativeTapSnippet.java | 12 ++--- .../tap/TapOnCoordinatesRelativeToScreen.java | 12 ++--- .../TapOnElementUsingCoordinatesAction.java | 12 ++--- .../automator/constants/TSCapabilityType.java | 2 +- .../drivers/mobile/MobileDriver.java | 2 +- .../automator/drivers/web/FirefoxDriver.java | 5 +- .../automator/drivers/web/SafariDriver.java | 3 ++ .../automator/drivers/web/WebDriver.java | 2 +- .../testsigma/constants/TSCapabilityType.java | 7 ++- .../testsigma/service/ChromeCapabilities.java | 1 - .../TestsigmaLabDriverSettingsService.java | 53 ++++++++++++++----- 35 files changed, 201 insertions(+), 174 deletions(-) diff --git a/automator/pom.xml b/automator/pom.xml index 50c27ed66..6c182152e 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -17,7 +17,7 @@ 2.2.0 2.8.5 4.8.2 - 8.4.0 + 8.3.0 9.4.12.v20180830 4.4 1.5.1 diff --git a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java index 29a603b87..2187cbec4 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/MobileDriverAction.java @@ -9,20 +9,14 @@ package com.testsigma.automator.actions.mobile; - import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.actions.DriverAction; import io.appium.java_client.AppiumDriver; - import io.appium.java_client.remote.MobileCapabilityType; import lombok.extern.log4j.Log4j2; - import org.openqa.selenium.remote.Command; - import org.openqa.selenium.remote.Response; - - @Log4j2 public abstract class MobileDriverAction extends DriverAction { diff --git a/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java b/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java index d2d2b8caa..17b60f48e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/SwipeAction.java @@ -38,12 +38,12 @@ public class SwipeAction extends MobileDriverAction { public void execute() throws Exception { PointOption startingPoint = PointOption.point(tapPoints[0].getX(), tapPoints[0].getY()); PointOption endingPoint = PointOption.point(tapPoints[1].getX(), tapPoints[1].getY()); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), tapPoints[0].getX(), tapPoints[0].getY())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), tapPoints[1].getX(), tapPoints[1].getY())) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), tapPoints[0].getX(), tapPoints[0].getY())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), tapPoints[1].getX(), tapPoints[1].getY())) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java b/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java index df951ff5c..f668d6ba9 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/TapPointAction.java @@ -34,12 +34,12 @@ public class TapPointAction extends MobileDriverAction { @Override public void execute() throws Exception { - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), tapPoint.getX(), tapPoint.getY())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, ofMillis(2))) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), tapPoint.getX(), tapPoint.getY())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, ofMillis(2))) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); } } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 1ee8a3fd9..53ae2fc3e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -93,12 +93,12 @@ private void clickOnReturnKeys() { try { getDriver().findElement(By.xpath("//*[contains(@name, '" + button + "')]")).click(); } catch (Exception e) { - log.error(e, e); + log.error("**Tried to hide keyboard by pressing return keys***", e); } try { getDriver().findElement(By.name(button)); } catch (Exception e) { - log.error(e, e); + log.error("**Couldnt find the button name***"+":"+button, e); } } ); diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java index a42ef1fdc..cb1ee87ec 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/presskey/LongPressOnElementAction.java @@ -29,12 +29,12 @@ protected void execute() throws Exception { WebElement targetElement = getElement(); int noOfSeconds = NumberFormatter.getIntegerValue(getTestData(), String.format(FAILURE_NOT_A_NUMBER, getTestData())); Duration time = Duration.ofSeconds(noOfSeconds); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, time)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, time)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData())); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java index 961f758d2..d20cf7445 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/press/LongPressSnippet.java @@ -37,12 +37,12 @@ public void execute() throws Exception { findElement(); WebElement targetElement = getElement(); Duration duration = Duration.ofSeconds(Long.parseLong(getTestData())); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, duration)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), targetElement.getLocation().getX(), targetElement.getLocation().getY())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, duration)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java index c9e134d69..0d61c1e92 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToMiddleSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.90); int endy = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java index ca4b7af17..444e5469e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeBottomToTopSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.90); int endy = (int) (size.height * 0.10); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java index c9a035d01..3c60561b6 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToBottomSnippet.java @@ -42,12 +42,12 @@ public void execute() throws Exception { int endy = (int) (size.height * 0.9); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java index 26a233ab9..f45d30dd1 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToLeftSnippet.java @@ -42,12 +42,12 @@ public void execute() throws Exception { int endy = targetElement.getLocation().getY(); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java index 1417918ea..2c20bc8cd 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToRightSnippet.java @@ -43,12 +43,12 @@ public void execute() throws Exception { int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java index da7815ecb..12a795316 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeElementToTopSnippet.java @@ -42,12 +42,12 @@ public void execute() throws Exception { int endy = (int) (size.height * 0.9); int x = targetElement.getLocation().getX(); int y = targetElement.getLocation().getY(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java index d68945d5a..163aba9fe 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToMiddleSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.10); int endx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java index 58be498e6..1431e5915 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeLeftToRightSnippet.java @@ -39,12 +39,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.10); int endx = (int) (size.width * 0.90); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java index 6a3388e12..11b41a0b7 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToBottomSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); int endy = (int) (size.height * 0.90); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java index e516cebf5..db53e8c15 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToLeftSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int endx = (int) (size.width * 0.10); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java index 3921be703..f2cffb2ca 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToRightSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int endx = (int) (size.width * 0.90); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java index c7e6f7fec..fba9e483c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeMiddleToTopSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); int endy = (int) (size.height * 0.10); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java index cf551769e..cbe30e0cb 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToLeftSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.90); int endx = (int) (size.width * 0.10); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java index 97c7cd281..b04af97b8 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeRightToMiddleSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.90); int endx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), endx, starty)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), endx, starty)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java index b21018f61..27eeaef5a 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToBottomSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.10); int endy = (int) (size.height * 0.90); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java index 30c8b806b..51eea3ad8 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/swipe/MobileNativeSwipeTopToMiddleSnippet.java @@ -38,12 +38,12 @@ public void execute() throws Exception { int startx = (int) (size.width * 0.50); int starty = (int) (size.height * 0.10); int endy = (int) (size.height * 0.50); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence swipe = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), startx, starty)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(FINGER.createPointerMove(ofSeconds(5), viewport(), startx, endy)) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence swipe = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), startx, starty)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(pointer.createPointerMove(ofSeconds(5), viewport(), startx, endy)) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(swipe)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java index eddb00217..0ffbcb98a 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java @@ -36,12 +36,12 @@ public void execute() throws Exception { String[] splitCoordiantes = getTestData().split(","); int x = Integer.parseInt(splitCoordiantes[0]); int y = Integer.parseInt(splitCoordiantes[1]); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), x, y)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, ofMillis(2))) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), x, y)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, ofMillis(2))) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java index 2c996fd22..4c33aeb25 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java @@ -33,12 +33,12 @@ public class MobileNativeTapSnippet extends MobileElementAction { @Override public void execute() throws Exception { findElement(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), getElement().getLocation().getX(), getElement().getLocation().getY())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, ofMillis(2))) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), getElement().getLocation().getX(), getElement().getLocation().getY())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, ofMillis(2))) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java index cdb922e95..dc755922d 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java @@ -41,12 +41,12 @@ protected void execute() throws Exception { Dimension screenDimension = getDriver().manage().window().getSize(); Double clickLocationX = (xPercent * screenDimension.getWidth() / 100); Double clickLocationY = (yPercent * screenDimension.getHeight() / 100); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), clickLocationX.intValue(), clickLocationY.intValue())) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, ofMillis(2))) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), clickLocationX.intValue(), clickLocationY.intValue())) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, ofMillis(2))) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(String.format(SUCCESS_MESSAGE, screenDimension.getWidth(), screenDimension.getHeight(), clickLocationX, clickLocationY)); } diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java index 64afef524..6f15c6f8e 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java @@ -26,12 +26,12 @@ protected void execute() throws Exception { findElement(); Rectangle rect = getElement().getRect(); - PointerInput FINGER = new PointerInput(TOUCH, "finger"); - Sequence tap = new Sequence(FINGER, 1) - .addAction(FINGER.createPointerMove(ofMillis(0), viewport(), rect.x + rect.width /2, rect.y + rect.height /2)) - .addAction(FINGER.createPointerDown(LEFT.asArg())) - .addAction(new Pause(FINGER, ofMillis(2))) - .addAction(FINGER.createPointerUp(LEFT.asArg())); + PointerInput pointer = new PointerInput(TOUCH, "finger"); + Sequence tap = new Sequence(pointer, 1) + .addAction(pointer.createPointerMove(ofMillis(0), viewport(), rect.x + rect.width /2, rect.y + rect.height /2)) + .addAction(pointer.createPointerDown(LEFT.asArg())) + .addAction(new Pause(pointer, ofMillis(2))) + .addAction(pointer.createPointerUp(LEFT.asArg())); getDriver().perform(Arrays.asList(tap)); setSuccessMessage(SUCCESS_MESSAGE); } diff --git a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java index 153f74e41..55bd760e9 100644 --- a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java +++ b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java @@ -10,7 +10,7 @@ public interface TSCapabilityType extends CapabilityType { String OS = "os"; String BUNDLE_ID = "bundleId"; String SELENIUM_VERSION = "seleniumVersion"; - String ACCEPT_SSL_CERTS = "acceptSslCerts"; + String ACCEPT_SSL_CERTS = "acceptInsecureCerts"; String UNHANDLED_PROMPT_BEHAVIOUR_KEY = "unhandledPromptBehavior"; String UNHANDLED_PROMPT_BEHAVIOUR_VALUE = "ignore"; String AVOID_PROXY = "avoidProxy"; diff --git a/automator/src/com/testsigma/automator/drivers/mobile/MobileDriver.java b/automator/src/com/testsigma/automator/drivers/mobile/MobileDriver.java index b67db048f..91513b536 100644 --- a/automator/src/com/testsigma/automator/drivers/mobile/MobileDriver.java +++ b/automator/src/com/testsigma/automator/drivers/mobile/MobileDriver.java @@ -48,12 +48,12 @@ protected void setCapabilities() throws AutomatorException, MalformedURLExceptio @Override protected void setCommonCapabilities() throws AutomatorException { super.setCommonCapabilities(); - capabilities.add(new WebDriverCapability(TSCapabilityType.NAME, executionName)); } @Override protected void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); + capabilities.add(new WebDriverCapability(TSCapabilityType.NAME, executionName)); setHybridRemoteServerUrl(settings.getAppiumUrl()); if (WorkspaceType.isIOSNative(testDeviceEntity.getWorkspaceType()) && (AppPathType.APP_DETAILS != settings.getAppPathType())) { diff --git a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java index ee8537c7f..2ffa99804 100644 --- a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java @@ -36,7 +36,6 @@ public FirefoxDriver() { @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { if (remoteServerURL != null) { - remoteWebDriver = new RemoteWebDriver(remoteServerURL, firefoxOptions.merge(desiredCapabilities)); } else { remoteWebDriver = new org.openqa.selenium.firefox.FirefoxDriver(new FirefoxOptions().merge(desiredCapabilities)); @@ -47,7 +46,7 @@ protected void createDriverInstance(DesiredCapabilities desiredCapabilities) thr public void setTestsigmaLabCapabilities() throws AutomatorException { if (!"Linux".equals(getPlatform())) { MutableCapabilities mutableCapabilities = new MutableCapabilities(); - mutableCapabilities.setCapability(TSCapabilityType.SELENIUM_VERSION, "3.8.1"); + mutableCapabilities.setCapability(TSCapabilityType.SELENIUM_VERSION, "4.8.2"); mutableCapabilities.setCapability(TSCapabilityType.NAME, executionName); mutableCapabilities.setCapability(EnvSettingsConstants.KEY_MAX_IDLE_TIME, EnvSettingsConstants.MAX_IDLE_TIME); mutableCapabilities.setCapability(EnvSettingsConstants.KEY_MAX_DURATION, EnvSettingsConstants.MAX_DURATION); @@ -58,7 +57,7 @@ public void setTestsigmaLabCapabilities() throws AutomatorException { } else { super.setTestsigmaLabCapabilities(); } - capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, Browser.FIREFOX)); + capabilities.add(new WebDriverCapability(CapabilityType.BROWSER_NAME, Browser.FIREFOX.browserName())); } protected void setAdditionalCapabilities(List additionalCapabilitiesList) { diff --git a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java index df85cb084..6ba802c1e 100644 --- a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java @@ -1,6 +1,8 @@ package com.testsigma.automator.drivers.web; import com.fasterxml.jackson.core.type.TypeReference; +import com.testsigma.automator.constants.TSCapabilityType; +import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.entity.ExecutionLabType; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.http.HttpClient; @@ -31,6 +33,7 @@ public SafariDriver() { @Override protected void createDriverInstance(DesiredCapabilities desiredCapabilities) throws AutomatorException { + desiredCapabilities.setAcceptInsecureCerts(false); if (remoteServerURL != null) { remoteWebDriver = new RemoteWebDriver(remoteServerURL, new SafariOptions().merge(desiredCapabilities)); } else { diff --git a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java index 6679ae406..17865c552 100644 --- a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java @@ -50,7 +50,6 @@ protected void setCapabilities() throws AutomatorException, MalformedURLExceptio @Override protected void setCommonCapabilities() throws AutomatorException { super.setCommonCapabilities(); - capabilities.add(new WebDriverCapability(TSCapabilityType.NAME, executionName)); capabilities.add(new WebDriverCapability(TSCapabilityType.ACCEPT_SSL_CERTS, Boolean.TRUE)); capabilities.add(new WebDriverCapability(TSCapabilityType.UNHANDLED_PROMPT_BEHAVIOUR_KEY, TSCapabilityType.UNHANDLED_PROMPT_BEHAVIOUR_VALUE)); } @@ -64,6 +63,7 @@ protected void setTestsigmaLabCapabilities() throws AutomatorException { @Override protected void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); + capabilities.add(new WebDriverCapability(TSCapabilityType.NAME, settings.getExecutionName())); } protected void setBrowserSpecificCapabilities(List additionalCapabilitiesList) diff --git a/server/src/main/java/com/testsigma/constants/TSCapabilityType.java b/server/src/main/java/com/testsigma/constants/TSCapabilityType.java index f27f7ea88..4951d50fa 100644 --- a/server/src/main/java/com/testsigma/constants/TSCapabilityType.java +++ b/server/src/main/java/com/testsigma/constants/TSCapabilityType.java @@ -2,7 +2,7 @@ public interface TSCapabilityType { String BROWSER_NAME = "browserName"; - String VERSION = "version"; + String VERSION = "browserVersion"; String DEVICE_ORIENTATION = "deviceOrientation"; String PORTRAIT = "portrait"; String UI_AUTOMATOR = "UiAutomator2"; @@ -32,7 +32,7 @@ public interface TSCapabilityType { String SKIP_DEVICE_INITIALIZATION = "skipDeviceInitialization"; String SKIP_SERVER_INSTALLATION = "skipServerInstallation"; String UDID = "udid"; - String OS_VERSION = "os_version"; + String OS_VERSION = "osVersion"; String OS = "os"; String TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION = "screenResolution"; @@ -42,4 +42,7 @@ public interface TSCapabilityType { int TESTSIGMA_LAB_COMMAND_TIMEOUT_VAL = 60 * 10 * 1000; String BROWSER_NAME_SAFARI = "safari"; + + String NAME = "name"; + String TESTSIGMA_LAB_OPTIONS = "testsigma:options"; } diff --git a/server/src/main/java/com/testsigma/service/ChromeCapabilities.java b/server/src/main/java/com/testsigma/service/ChromeCapabilities.java index 21da1322d..9670d11ba 100644 --- a/server/src/main/java/com/testsigma/service/ChromeCapabilities.java +++ b/server/src/main/java/com/testsigma/service/ChromeCapabilities.java @@ -16,7 +16,6 @@ public class ChromeCapabilities extends Capabilities { public void setTestsigmaLabCapabilities(TestDevice testDevice, Integrations integrations, List capabilities) { - capabilities.add(new WebDriverCapability(TSCapabilityType.EXTENDED_DEBUGGING, true)); capabilities.add(new WebDriverCapability(TSCapabilityType.BROWSER_NAME, BrowserType.CHROME)); } diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index eac27a790..51b82d355 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -1,13 +1,18 @@ package com.testsigma.service; +import com.testsigma.automator.entity.TestDeviceEntity; +import com.testsigma.automator.runners.EnvironmentRunner; import com.testsigma.constants.TSCapabilityType; import com.testsigma.dto.WebDriverSettingsDTO; import com.testsigma.exception.IntegrationNotFoundException; import com.testsigma.exception.TestsigmaException; import com.testsigma.model.*; +import com.twilio.rest.api.v2010.Account; import lombok.extern.log4j.Log4j2; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.web.context.WebApplicationContext; @@ -16,6 +21,7 @@ import java.net.URL; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; @Service @@ -26,6 +32,9 @@ public class TestsigmaLabDriverSettingsService extends DriverSettingsService { public static final String PLATFORM_MOBILE_URL = "%s://%s:%s@%s/mobile/wd/hub"; public static final String PLATFORM_MOBILE_URL_WITH_PORT = "%s://%s:%s@%s:%s/mobile/wd/hub"; + protected TestDeviceEntity testDeviceEntity; + protected com.testsigma.automator.entity.TestDeviceSettings settings; + @Autowired PlatformsService platformsService; @Autowired @@ -72,9 +81,9 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace PlatformDevice device = platformsService.getPlatformDevice(testDevice.getPlatformDeviceId(), testDevice.getTestPlanLabType()); PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(),testDevice.getTestPlanLabType()); Platform os = device.getPlatform(); + HashMap tsLabOptions = new HashMap(); capabilities.add(new WebDriverCapability(TSCapabilityType.DEVICE_NAME, device.getName() == null ? device.getDisplayName() : device.getName())); capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM_VERSION, platformOsVersion.getPlatformVersion())); - capabilities.add(new WebDriverCapability(TSCapabilityType.DEVICE_ORIENTATION, TSCapabilityType.PORTRAIT)); if (Platform.Android.equals(os)) { capabilities.add(new WebDriverCapability(TSCapabilityType.AUTOMATION_NAME, TSCapabilityType.UI_AUTOMATOR)); } else if (Platform.iOS.equals(os)) { @@ -86,8 +95,9 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace } capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_CAP, TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_VAL)); - capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_COMMAND_TIMEOUT_CAP, - TSCapabilityType.TESTSIGMA_LAB_COMMAND_TIMEOUT_VAL)); + tsLabOptions.put(TSCapabilityType.NAME,getExecutionName()); + tsLabOptions.put(TSCapabilityType.DEVICE_ORIENTATION, TSCapabilityType.PORTRAIT); + capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS,tsLabOptions)); if (webDriverSettings.getWebDriverCapabilities() != null) webDriverSettings.getWebDriverCapabilities().addAll(capabilities); else @@ -109,20 +119,22 @@ public void setWebCapabilities(TestDevice testDevice, PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testDevice.getTestPlanLabType()); PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), testDevice.getTestPlanLabType()); PlatformScreenResolution platformScreenResolution = platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), testDevice.getTestPlanLabType()); - capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM, platformOsVersion.getPlatformVersion())); - capabilities.add(new WebDriverCapability(TSCapabilityType.OS, platformOsVersion.getPlatform())); - capabilities.add(new WebDriverCapability(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion())); - + HashMap tsLabOptions = new HashMap(); + capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM_NAME, platformOsVersion.getPlatformVersion())); capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION, platformBrowserVersion.getVersion())); String resolution = platformScreenResolution.getResolution(); if (!StringUtils.isBlank(resolution)) { - capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, resolution)); + tsLabOptions.put(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, resolution); } else { - capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, - TSCapabilityType.DEFAULT_RESOLUTION)); + tsLabOptions.put(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, + TSCapabilityType.DEFAULT_RESOLUTION); } - capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME)); - capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION)); + tsLabOptions.put(TSCapabilityType.NAME,getExecutionName()); + tsLabOptions.put(TSCapabilityType.OS, platformOsVersion.getPlatform()); + tsLabOptions.put(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion()); + tsLabOptions.put(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME); + tsLabOptions.put(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION); + capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS,tsLabOptions)); if (webDriverSettings.getWebDriverCapabilities() != null) webDriverSettings.getWebDriverCapabilities().addAll(capabilities); else @@ -138,4 +150,21 @@ public void setWebCapabilities(TestDevice testDevice, public Integrations getLabDetails() throws IntegrationNotFoundException { return this.integrationsService.findByApplication(Integration.TestsigmaLab); } + + private String getExecutionName() { + String name = "[Trial] - Mobile Inspection"; + testDeviceEntity = EnvironmentRunner.getRunnerEnvironmentEntity(); + if (testDeviceEntity != null) { + this.settings = testDeviceEntity.getEnvSettings(); + if(settings != null){ + String runBy = ObjectUtils.defaultIfNull(settings.getRunBy(), ""); + String executionRunId = settings.getExecutionRunId().toString(); + String executionName = settings.getExecutionName(); + name = String.format("[%s] - %s - %s", executionRunId, runBy, executionName); + name = name.replaceAll("[^a-zA-Z1-90_\\s\\[\\]\\:\\-@\\.]*", ""); + } + } + return name; + } + } From a91f0120993b8c0316a168a1f0178044aff4c63e Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 16 May 2023 18:13:03 +0530 Subject: [PATCH 19/41] TRD-217 Handled proxy capability as per W3C standards. --- .../com/testsigma/automator/constants/TSCapabilityType.java | 2 +- .../src/com/testsigma/automator/drivers/web/EdgeDriver.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java index 55bd760e9..a70f828c5 100644 --- a/automator/src/com/testsigma/automator/constants/TSCapabilityType.java +++ b/automator/src/com/testsigma/automator/constants/TSCapabilityType.java @@ -13,7 +13,7 @@ public interface TSCapabilityType extends CapabilityType { String ACCEPT_SSL_CERTS = "acceptInsecureCerts"; String UNHANDLED_PROMPT_BEHAVIOUR_KEY = "unhandledPromptBehavior"; String UNHANDLED_PROMPT_BEHAVIOUR_VALUE = "ignore"; - String AVOID_PROXY = "avoidProxy"; + String AVOID_PROXY = "proxy"; String BROWSER_DRIVER_PROPERTY_CHROME = "webdriver.chrome.driver"; String BROWSER_DRIVER_PROPERTY_FIREFOX = "webdriver.gecko.driver"; String BROWSER_DRIVER_PROPERTY_EDGE = "webdriver.edge.driver"; diff --git a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java index c3024505c..54494cb91 100644 --- a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java @@ -1,5 +1,6 @@ package com.testsigma.automator.drivers.web; +import com.google.gson.JsonObject; import com.testsigma.automator.constants.TSCapabilityType; import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.exceptions.AutomatorException; @@ -7,6 +8,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.log4j.Log4j2; +import org.json.JSONObject; import org.openqa.selenium.edge.EdgeOptions; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -46,6 +48,8 @@ public void setHybridCapabilities() throws AutomatorException, MalformedURLExcep @Override protected void setBrowserSpecificCapabilities(List additionalCapabilitiesList) throws AutomatorException { - capabilities.add(new WebDriverCapability(TSCapabilityType.AVOID_PROXY, Boolean.TRUE)); + JSONObject proxyOptions=new JSONObject(); + proxyOptions.put("proxyType","system"); + capabilities.add(new WebDriverCapability(TSCapabilityType.AVOID_PROXY, proxyOptions)); } } From 052178a0ee6441d0b00a72cf715e168773f330cf Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 16 May 2023 18:48:27 +0530 Subject: [PATCH 20/41] TRD-217 Removed unused import --- .../src/com/testsigma/automator/drivers/web/EdgeDriver.java | 1 - .../testsigma/service/TestsigmaLabDriverSettingsService.java | 3 --- 2 files changed, 4 deletions(-) diff --git a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java index 54494cb91..72f209ff9 100644 --- a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java @@ -1,6 +1,5 @@ package com.testsigma.automator.drivers.web; -import com.google.gson.JsonObject; import com.testsigma.automator.constants.TSCapabilityType; import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.exceptions.AutomatorException; diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index 51b82d355..960d0169d 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -7,15 +7,12 @@ import com.testsigma.exception.IntegrationNotFoundException; import com.testsigma.exception.TestsigmaException; import com.testsigma.model.*; -import com.twilio.rest.api.v2010.Account; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.web.context.WebApplicationContext; - import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; From 7aaf8341114f74bbd22ba24bfabf58559268ef51 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Thu, 18 May 2023 21:10:54 +0530 Subject: [PATCH 21/41] TRD-217 Addressing Review comments. --- .../ios/generic/HideKeyboardAction.java | 4 +- .../service/DriverSettingsService.java | 18 ++++---- .../service/HybridDriverSettingsService.java | 10 ++--- .../PrivateGridDriverSettingsService.java | 8 ++-- .../TestsigmaLabDriverSettingsService.java | 41 ++++++++----------- .../service/WebDriverSettingsService.java | 12 ++++-- 6 files changed, 44 insertions(+), 49 deletions(-) diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 53ae2fc3e..46b692969 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -56,9 +56,9 @@ protected void execute() throws Exception { private void switchToActiveElementAndPressEnter() { try { getDriver().switchTo().activeElement().sendKeys(Keys.RETURN); - log.error("Hide keyboard by switching to active element and clicking enter"); + log.info("Hide keyboard by switching to active element and clicking enter"); } catch (Exception e) { - log.error("Could not hide keyboard by switching to active element and clicking enter"); + log.error("Could not hide keyboard by switching to active element and clicking enter",e); } } diff --git a/server/src/main/java/com/testsigma/service/DriverSettingsService.java b/server/src/main/java/com/testsigma/service/DriverSettingsService.java index 55ea4c11a..77fd6ee98 100644 --- a/server/src/main/java/com/testsigma/service/DriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/DriverSettingsService.java @@ -29,20 +29,20 @@ public abstract URL getRemoteDriverUrl(String url, Integrations integrations) throws MalformedURLException; public WebDriverSettingsDTO driverSettings(TestDevice testDevice, WorkspaceType workspaceType, - TestPlanLabType testPlanLabType, + TestPlanLabType testPlanLabType,TestPlanResult testPlanResult, Integrations integrations, WebApplicationContext webApplicationContext) throws IOException, TestsigmaException, SQLException { WebDriverSettingsDTO webDriverSettings = new WebDriverSettingsDTO(); workspaceType = testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType(); - webDriverSettings.setWebDriverCapabilities(getCapabilities(testDevice, workspaceType, testPlanLabType, + webDriverSettings.setWebDriverCapabilities(getCapabilities(testDevice, workspaceType, testPlanLabType,testPlanResult, integrations, webApplicationContext)); - setApplicationSpecificCapabilities(testDevice, workspaceType, integrations, webDriverSettings); + setApplicationSpecificCapabilities(testDevice, workspaceType, testPlanResult, integrations, webDriverSettings); return webDriverSettings; } public List getCapabilities(TestDevice testDevice, - WorkspaceType workspaceType, TestPlanLabType testPlanLabType, + WorkspaceType workspaceType, TestPlanLabType testPlanLabType,TestPlanResult testPlanResult, Integrations integrations, WebApplicationContext webApplicationContext) throws TestsigmaException, IOException { @@ -59,7 +59,7 @@ else if (testDevice.getPlatformBrowserVersionId() != null) { return capabilities.getCapabilities(testDevice, integrations, testPlanLabType); } - public void setWebCapabilities(TestDevice testDevice, + public void setWebCapabilities(TestDevice testDevice,TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws MalformedURLException, TestsigmaException { @@ -75,26 +75,26 @@ public void setWebCapabilities(TestDevice testDevice, } public void setApplicationSpecificCapabilities(TestDevice testDevice, - WorkspaceType workspaceType, + WorkspaceType workspaceType,TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException { switch (workspaceType) { case WebApplication: - setWebCapabilities(testDevice, integrations, webDriverSettings); + setWebCapabilities(testDevice, testPlanResult, integrations, webDriverSettings); break; case MobileWeb: case IOSWeb: case AndroidNative: case IOSNative: - setMobileCapabilities(testDevice, workspaceType, integrations, webDriverSettings); + setMobileCapabilities(testDevice, workspaceType, testPlanResult, integrations, webDriverSettings); break; } } public abstract Integrations getLabDetails() throws IntegrationNotFoundException; - public abstract void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, + public abstract void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType,TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException; diff --git a/server/src/main/java/com/testsigma/service/HybridDriverSettingsService.java b/server/src/main/java/com/testsigma/service/HybridDriverSettingsService.java index e7c985152..d2f792cb6 100644 --- a/server/src/main/java/com/testsigma/service/HybridDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/HybridDriverSettingsService.java @@ -25,21 +25,21 @@ public class HybridDriverSettingsService extends DriverSettingsService { @Override public WebDriverSettingsDTO driverSettings(TestDevice testDevice, WorkspaceType workspaceType, - TestPlanLabType testPlanLabType, + TestPlanLabType testPlanLabType,TestPlanResult testPlanResult, Integrations integrations, WebApplicationContext webApplicationContext) throws IOException, TestsigmaException, SQLException { WebDriverSettingsDTO webDriverSettings = new WebDriverSettingsDTO(); List webDriverCapabilities = getCapabilities(testDevice, workspaceType, - testPlanLabType, integrations, webApplicationContext); + testPlanLabType, testPlanResult, integrations, webApplicationContext); webDriverSettings.setWebDriverCapabilities(webDriverCapabilities); - setApplicationSpecificCapabilities(testDevice, workspaceType, integrations, webDriverSettings); + setApplicationSpecificCapabilities(testDevice, workspaceType, testPlanResult, integrations, webDriverSettings); webDriverSettings.setWebDriverServerUrl(getRemoteDriverUrl(LOCAL_HOST_URL, integrations)); return webDriverSettings; } @Override - public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, + public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException { @@ -67,7 +67,7 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace } @Override - public void setWebCapabilities(TestDevice testDevice, + public void setWebCapabilities(TestDevice testDevice, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws MalformedURLException { } diff --git a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java index 7ea9835f9..1606aaf6b 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java @@ -33,11 +33,11 @@ public class PrivateGridDriverSettingsService extends DriverSettingsService { @Override public WebDriverSettingsDTO driverSettings(TestDevice testDevice, WorkspaceType workspaceType, - TestPlanLabType testPlanLabType, + TestPlanLabType testPlanLabType, TestPlanResult testPlanResult, Integrations integrations, WebApplicationContext webApplicationContext) throws IOException, TestsigmaException, SQLException { - return super.driverSettings(testDevice, workspaceType, testPlanLabType, integrations, + return super.driverSettings(testDevice, workspaceType, testPlanLabType, testPlanResult, integrations, webApplicationContext); } @@ -56,7 +56,7 @@ public URL getRemoteDriverUrl(String url, Integrations integrations) @Override - public void setWebCapabilities(TestDevice testDevice, + public void setWebCapabilities(TestDevice testDevice, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws MalformedURLException, TestsigmaException { @@ -88,7 +88,7 @@ public Integrations getLabDetails() throws IntegrationNotFoundException { } @Override - public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException { + public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException { } } diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index 960d0169d..c98e48c37 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -1,14 +1,11 @@ package com.testsigma.service; -import com.testsigma.automator.entity.TestDeviceEntity; -import com.testsigma.automator.runners.EnvironmentRunner; import com.testsigma.constants.TSCapabilityType; import com.testsigma.dto.WebDriverSettingsDTO; import com.testsigma.exception.IntegrationNotFoundException; import com.testsigma.exception.TestsigmaException; import com.testsigma.model.*; import lombok.extern.log4j.Log4j2; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -29,8 +26,7 @@ public class TestsigmaLabDriverSettingsService extends DriverSettingsService { public static final String PLATFORM_MOBILE_URL = "%s://%s:%s@%s/mobile/wd/hub"; public static final String PLATFORM_MOBILE_URL_WITH_PORT = "%s://%s:%s@%s:%s/mobile/wd/hub"; - protected TestDeviceEntity testDeviceEntity; - protected com.testsigma.automator.entity.TestDeviceSettings settings; + @Autowired PlatformsService platformsService; @@ -41,11 +37,11 @@ public class TestsigmaLabDriverSettingsService extends DriverSettingsService { @Override public WebDriverSettingsDTO driverSettings(TestDevice testDevice, WorkspaceType workspaceType, - TestPlanLabType testPlanLabType, + TestPlanLabType testPlanLabType,TestPlanResult testPlanResult, Integrations integrations, WebApplicationContext webApplicationContext) throws IOException, TestsigmaException, SQLException { - return super.driverSettings(testDevice, workspaceType, testPlanLabType, integrations, + return super.driverSettings(testDevice, workspaceType, testPlanLabType, testPlanResult, integrations, webApplicationContext); } @@ -70,7 +66,7 @@ public URL getRemoteDriverUrl(String url, Integrations integrations) } @Override - public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, + public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspaceType, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws TestsigmaException, MalformedURLException { @@ -92,7 +88,7 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace } capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_CAP, TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_VAL)); - tsLabOptions.put(TSCapabilityType.NAME,getExecutionName()); + tsLabOptions.put(TSCapabilityType.NAME,getExecutionName(testPlanResult)); tsLabOptions.put(TSCapabilityType.DEVICE_ORIENTATION, TSCapabilityType.PORTRAIT); capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS,tsLabOptions)); if (webDriverSettings.getWebDriverCapabilities() != null) @@ -107,7 +103,7 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace } @Override - public void setWebCapabilities(TestDevice testDevice, + public void setWebCapabilities(TestDevice testDevice,TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws MalformedURLException, TestsigmaException { @@ -126,7 +122,7 @@ public void setWebCapabilities(TestDevice testDevice, tsLabOptions.put(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, TSCapabilityType.DEFAULT_RESOLUTION); } - tsLabOptions.put(TSCapabilityType.NAME,getExecutionName()); + tsLabOptions.put(TSCapabilityType.NAME,getExecutionName(testPlanResult)); tsLabOptions.put(TSCapabilityType.OS, platformOsVersion.getPlatform()); tsLabOptions.put(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion()); tsLabOptions.put(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME); @@ -148,20 +144,15 @@ public Integrations getLabDetails() throws IntegrationNotFoundException { return this.integrationsService.findByApplication(Integration.TestsigmaLab); } - private String getExecutionName() { - String name = "[Trial] - Mobile Inspection"; - testDeviceEntity = EnvironmentRunner.getRunnerEnvironmentEntity(); - if (testDeviceEntity != null) { - this.settings = testDeviceEntity.getEnvSettings(); - if(settings != null){ - String runBy = ObjectUtils.defaultIfNull(settings.getRunBy(), ""); - String executionRunId = settings.getExecutionRunId().toString(); - String executionName = settings.getExecutionName(); - name = String.format("[%s] - %s - %s", executionRunId, runBy, executionName); - name = name.replaceAll("[^a-zA-Z1-90_\\s\\[\\]\\:\\-@\\.]*", ""); - } - } - return name; + public String getExecutionName(TestPlanResult testPlanDetails) { + String name = "Open source execution run"; + if(testPlanDetails!= null){ + String executionRunId = testPlanDetails.getId().toString(); + String executionName = testPlanDetails.getTestPlan().getName(); + name = String.format("[%s] - %s", executionRunId, executionName); + name = name.replaceAll("[^a-zA-Z1-90_\\s\\[\\]\\:\\-@\\.]*", ""); } + return name; + } } diff --git a/server/src/main/java/com/testsigma/service/WebDriverSettingsService.java b/server/src/main/java/com/testsigma/service/WebDriverSettingsService.java index 70f302d77..7e4da05bb 100644 --- a/server/src/main/java/com/testsigma/service/WebDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/WebDriverSettingsService.java @@ -36,9 +36,12 @@ public class WebDriverSettingsService { private final TestDeviceResultService testDeviceResultService; private final TestDeviceService testDeviceService; + private final TestPlanResultService testPlanResultService; + public WebDriverSettingsDTO getWebDriverSettings(WebDriverSettingsRequest webDriverSettingsRequest) throws SQLException, TestsigmaException, IOException { TestDevice testDevice = new TestDevice(); + TestPlanResult testPlanResult = new TestPlanResult(); WorkspaceType workspaceType = webDriverSettingsRequest.getWorkspaceType(); MobileInspection mobileInspection = this.mobileInspectionService.find(webDriverSettingsRequest.getMobileSessionId()); @@ -63,7 +66,7 @@ public WebDriverSettingsDTO getWebDriverSettings(WebDriverSettingsRequest webDri testDevice.setDeviceId(mobileInspection.getAgentDeviceId()); WebDriverSettingsDTO webDriverSettingsDTO = getDriverCapabilities(testDevice, workspaceType, - webDriverSettingsRequest.getExecutionLabType()); + webDriverSettingsRequest.getExecutionLabType(), testPlanResult); List capabilitiesSettings = mobileInspection.getCapabilities(); List desiredCapabilities = new ArrayList<>(); @@ -77,11 +80,11 @@ public WebDriverSettingsDTO getWebDriverSettings(WebDriverSettingsRequest webDri } public WebDriverSettingsDTO getDriverCapabilities(TestDevice testDevice, - WorkspaceType workspaceType, TestPlanLabType testPlanLabType) + WorkspaceType workspaceType, TestPlanLabType testPlanLabType,TestPlanResult testPlanResult) throws SQLException, TestsigmaException, IOException { DriverSettingsServiceFactory driverSettingsServiceFactory = new DriverSettingsServiceFactory(webApplicationContext); DriverSettingsService driverSettingsService = driverSettingsServiceFactory.driverSettingsService(testPlanLabType); - return driverSettingsService.driverSettings(testDevice, workspaceType, testPlanLabType, + return driverSettingsService.driverSettings(testDevice, workspaceType, testPlanLabType, testPlanResult, driverSettingsService.getLabDetails(), webApplicationContext); } @@ -92,6 +95,7 @@ public WebDriverSettingsDTO getCapabilities(long id) throws TestsigmaException, .getWorkspaceVersion().getWorkspace().getWorkspaceType(); TestPlanLabType testPlanLabType = testDeviceResult.getTestDevice() .getTestPlanLabType(); - return getDriverCapabilities(testDevice, workspaceType, testPlanLabType); + TestPlanResult testPlanResult = testPlanResultService.find(testDeviceResult.getTestPlanResultId()); + return getDriverCapabilities(testDevice, workspaceType, testPlanLabType, testPlanResult); } } From 4e52ce44fcc9df0f95b0a75f6d67c9079c9137a4 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Fri, 19 May 2023 14:47:54 +0530 Subject: [PATCH 22/41] TRD-217 Addressing review comments --- .../TestsigmaLabDriverSettingsService.java | 15 ++------------- server/src/main/resources/application.properties | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index c98e48c37..5f76df62d 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -88,7 +88,7 @@ public void setMobileCapabilities(TestDevice testDevice, WorkspaceType workspace } capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_CAP, TSCapabilityType.TESTSIGMA_LAB_NEW_COMMAND_TIMEOUT_VAL)); - tsLabOptions.put(TSCapabilityType.NAME,getExecutionName(testPlanResult)); + tsLabOptions.put(TSCapabilityType.NAME,testPlanResult.getTestPlan().getName()); tsLabOptions.put(TSCapabilityType.DEVICE_ORIENTATION, TSCapabilityType.PORTRAIT); capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS,tsLabOptions)); if (webDriverSettings.getWebDriverCapabilities() != null) @@ -122,7 +122,7 @@ public void setWebCapabilities(TestDevice testDevice,TestPlanResult testPlanResu tsLabOptions.put(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, TSCapabilityType.DEFAULT_RESOLUTION); } - tsLabOptions.put(TSCapabilityType.NAME,getExecutionName(testPlanResult)); + tsLabOptions.put(TSCapabilityType.NAME,testPlanResult.getTestPlan().getName()); tsLabOptions.put(TSCapabilityType.OS, platformOsVersion.getPlatform()); tsLabOptions.put(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion()); tsLabOptions.put(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME); @@ -144,15 +144,4 @@ public Integrations getLabDetails() throws IntegrationNotFoundException { return this.integrationsService.findByApplication(Integration.TestsigmaLab); } - public String getExecutionName(TestPlanResult testPlanDetails) { - String name = "Open source execution run"; - if(testPlanDetails!= null){ - String executionRunId = testPlanDetails.getId().toString(); - String executionName = testPlanDetails.getTestPlan().getName(); - name = String.format("[%s] - %s", executionRunId, executionName); - name = name.replaceAll("[^a-zA-Z1-90_\\s\\[\\]\\:\\-@\\.]*", ""); - } - return name; - } - } diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index 1591668b5..f80a5c34f 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -1,6 +1,6 @@ server.port=${TESTSIGMA_SERVER_PORT:9090} server.url=${TESTSIGMA_SERVER_URL:https://local.testsigmaos.com} -server.version=v2.9.2 +server.version=v3.0.0 server.local.url=${TESTSIGMA_SERVER_LOCAL_URL:http://localhost:${server.port}} local.agent.url=${LOCAL_AGENT_URL:http://localhost:9393/agent} local.agent.download.tag=latest From 6223dc452b3e352970b4f66c95c42ef2e44006f7 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 22 May 2023 11:25:40 +0530 Subject: [PATCH 23/41] TRD-217 Changing testsigma java sdk version --- automator/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automator/pom.xml b/automator/pom.xml index 6c182152e..00fd3fb6d 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -296,7 +296,7 @@ com.testsigma testsigma-java-sdk - 1.2.0_beta_1 + 1.2.0.beta_selenium4_1 From 8be562e00382fccb02f5e7e75d1da1fc189f7403 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 22 May 2023 13:27:11 +0530 Subject: [PATCH 24/41] TRD-217 upgrading agent version --- agent/src/main/resources/agent.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/main/resources/agent.properties b/agent/src/main/resources/agent.properties index ae678138f..65b241ab2 100644 --- a/agent/src/main/resources/agent.properties +++ b/agent/src/main/resources/agent.properties @@ -9,4 +9,4 @@ cloud.url=${CLOUD_URL:https://local.testsigmaos.com} local.server.url=${LOCAL_SERVER_URL:http://localhost:9090} local.agent.register=${LOCAL_AGENT_REGISTER:true} -agent.version=2.9.2 +agent.version=3.0.0 From 7f83678f23d13f4de0aed1ef656fd451e58893f9 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Mon, 22 May 2023 14:12:36 +0530 Subject: [PATCH 25/41] TRD-217 upgrading agent version --- server/src/main/java/com/testsigma/dto/AgentDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/testsigma/dto/AgentDTO.java b/server/src/main/java/com/testsigma/dto/AgentDTO.java index 35252f727..e38b164d8 100644 --- a/server/src/main/java/com/testsigma/dto/AgentDTO.java +++ b/server/src/main/java/com/testsigma/dto/AgentDTO.java @@ -30,5 +30,5 @@ public class AgentDTO { private String hostName; private AgentOs osType; private String osVersion; - private String currentAgentVersion = "2.9.2"; + private String currentAgentVersion = "3.0.0"; } From ca66b7246eb3d58b261edc7a65f5a3dbe79cedfb Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 23 May 2023 18:01:47 +0530 Subject: [PATCH 26/41] TRD-217 Pointing proxy to staging instance for testing --- server/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index f80a5c34f..d129d21fc 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -5,7 +5,7 @@ server.local.url=${TESTSIGMA_SERVER_LOCAL_URL:http://localhost:${server.port}} local.agent.url=${LOCAL_AGENT_URL:http://localhost:9393/agent} local.agent.download.tag=latest docker.env=${IS_DOCKER_ENV:false} -testsigma.platform.url=${TESTSIGMA_PLATFORM_URL:https://os-services.testsigma.com} +testsigma.platform.url=${TESTSIGMA_PLATFORM_URL:https://staging-os-services.testsigma.com} ts.root.dir=${TS_DATA_DIR:/opt/app/ts_data} unzip.dir=${UNZIP_HOME_DIR:/usr/bin/} ts.disable.telemetry=${DISABLE_TELEMETRY: false} From e3883f6ad229e9ce15350ae253c83c3aa36adf0d Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Thu, 25 May 2023 14:32:42 +0530 Subject: [PATCH 27/41] (feat): private grid + se4 features --- .../actions/CustomExpectedConditions.java | 7 +- .../automator/actions/ElementAction.java | 2 +- .../generic/ElementScreenshotSnippet.java | 6 + .../generic/OpenNewBrowserWindowSnippet.java | 6 + .../store/StoreElementDimensionSnippet.java | 4 + .../web/generic/ElementScreenshotAction.java | 14 ++ .../generic/OpenNewBrowserWindowAction.java | 121 ++++++++++++++++++ .../store/StoreElementDimensionsAction.java | 55 ++++++++ .../constants/AutomatorMessages.java | 2 + .../constants/NaturalTextActionConstants.java | 5 + .../automator/runners/TestcaseStepRunner.java | 12 ++ .../utilities/ScreenCaptureUtil.java | 30 ++++- .../PrivateGridDriverSettingsService.java | 42 ++++-- .../testsigma/service/PrivateGridService.java | 94 ++++++++------ .../V207__bootstrap_natural_text_actions.sql | 9 ++ .../db/migration/V65__selenium4_nlp.sql | 14 ++ 16 files changed, 371 insertions(+), 52 deletions(-) create mode 100644 automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/ElementScreenshotSnippet.java create mode 100644 automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/OpenNewBrowserWindowSnippet.java create mode 100644 automator/src/com/testsigma/automator/actions/mobile/mobileweb/store/StoreElementDimensionSnippet.java create mode 100644 automator/src/com/testsigma/automator/actions/web/generic/ElementScreenshotAction.java create mode 100644 automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java create mode 100644 automator/src/com/testsigma/automator/actions/web/store/StoreElementDimensionsAction.java create mode 100644 server/src/main/resources/db/migration/V65__selenium4_nlp.sql diff --git a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java index 075ecede8..7b85f0eba 100644 --- a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java +++ b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java @@ -5,12 +5,15 @@ import org.openqa.selenium.remote.UnreachableBrowserException; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.FluentWait; import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; import java.util.List; import java.util.Set; +import static java.util.concurrent.TimeUnit.SECONDS; + @Log4j2 public class CustomExpectedConditions { @@ -199,13 +202,13 @@ public Boolean apply(WebDriver driver) { }; } - final static public void explictWait(WebDriver driver, By by, Integer wait) { + final static public void explicitWait(WebDriver driver, By by, Integer wait) { if (wait == null || wait < 1 || wait > 120) { return; } if (by != null) { - (new WebDriverWait(driver, Duration.ofSeconds(wait))).until(ExpectedConditions.presenceOfElementLocated(by)); + new FluentWait<>(driver).withTimeout(Duration.ofSeconds(wait)).pollingEvery(Duration.ofSeconds(10)).ignoring(NoSuchElementException.class); } } } diff --git a/automator/src/com/testsigma/automator/actions/ElementAction.java b/automator/src/com/testsigma/automator/actions/ElementAction.java index 3272f9e2b..a677cde51 100644 --- a/automator/src/com/testsigma/automator/actions/ElementAction.java +++ b/automator/src/com/testsigma/automator/actions/ElementAction.java @@ -63,7 +63,7 @@ protected void findElement(String elementActionVariableName) throws Exception { log.info("Finding an element for Action variable: " + elementActionVariableName); setElementSearchCriteria(elementActionVariableName); log.info(String.format("Finding element with criteria: %s, Explicit timeout as: %s", elementSearchCriteria, getTimeout())); - CustomExpectedConditions.explictWait(getDriver(), elementSearchCriteria.getBy(), (int)getTimeout().getSeconds()); + CustomExpectedConditions.explicitWait(getDriver(), elementSearchCriteria.getBy(), (int)getTimeout().getSeconds()); elements = getDriver().findElements(elementSearchCriteria.getBy()); log.info("No of elements found: " + elements.size()); if (!elements.isEmpty()) { diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/ElementScreenshotSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/ElementScreenshotSnippet.java new file mode 100644 index 000000000..d999f1aab --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/ElementScreenshotSnippet.java @@ -0,0 +1,6 @@ +package com.testsigma.automator.actions.mobile.mobileweb.generic; + +import com.testsigma.automator.actions.web.generic.ElementScreenshotAction; + +public class ElementScreenshotSnippet extends ElementScreenshotAction { +} diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/OpenNewBrowserWindowSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/OpenNewBrowserWindowSnippet.java new file mode 100644 index 000000000..f5d2daef6 --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/generic/OpenNewBrowserWindowSnippet.java @@ -0,0 +1,6 @@ +package com.testsigma.automator.actions.mobile.mobileweb.generic; + +import com.testsigma.automator.actions.web.generic.OpenNewBrowserWindowAction; + +public class OpenNewBrowserWindowSnippet extends OpenNewBrowserWindowAction { +} diff --git a/automator/src/com/testsigma/automator/actions/mobile/mobileweb/store/StoreElementDimensionSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/store/StoreElementDimensionSnippet.java new file mode 100644 index 000000000..5bfb3a2d0 --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/mobile/mobileweb/store/StoreElementDimensionSnippet.java @@ -0,0 +1,4 @@ +package com.testsigma.automator.actions.mobile.mobileweb.store; + +public class StoreElementDimensionSnippet extends com.testsigma.automator.actions.web.store.StoreElementDimensionsAction { +} diff --git a/automator/src/com/testsigma/automator/actions/web/generic/ElementScreenshotAction.java b/automator/src/com/testsigma/automator/actions/web/generic/ElementScreenshotAction.java new file mode 100644 index 000000000..ac5a35f48 --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/web/generic/ElementScreenshotAction.java @@ -0,0 +1,14 @@ +package com.testsigma.automator.actions.web.generic; + +import com.testsigma.automator.actions.ElementAction; +import lombok.extern.log4j.Log4j2; + +@Log4j2 +public class ElementScreenshotAction extends ElementAction { + + @Override + public void execute() throws Exception { + findElement(); + log.info("Element screenshot is handled post test step execution."); + } +} diff --git a/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java b/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java new file mode 100644 index 000000000..0e3602b5b --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java @@ -0,0 +1,121 @@ +package com.testsigma.automator.actions.web.generic; + +import com.testsigma.automator.actions.ElementAction; +import com.testsigma.automator.actions.constants.ErrorCodes; +import org.apache.http.HttpStatus; +import org.openqa.selenium.*; +import org.openqa.selenium.remote.UnreachableBrowserException; +import lombok.extern.log4j.Log4j2; + +import java.io.IOException; +import java.net.*; + +@Log4j2 +public class OpenNewBrowserWindowAction extends ElementAction { + private static final String SUCCESS_MESSAGE = "Successfully opened given URL."; + + @Override + protected void execute() throws Exception { + String navigationUrl = getTestData().trim(); + log.info("Opening a new browser window and navigating to - " + navigationUrl); + getDriver().switchTo().newWindow(WindowType.WINDOW); + getDriver().navigate().to(navigationUrl); + setSuccessMessage(SUCCESS_MESSAGE); + } + + @Override + protected void handleException(Exception e) { + super.handleException(e); + if (e instanceof UnreachableBrowserException || e instanceof NoSuchSessionException) { + //These two exception types are already handled in super class. + } else if (e instanceof TimeoutException) { + setErrorMessage(String.format("The Web Page with URL \"%s\" failed to load within the configured page load timeout duration. " + + "Please increase the 'page load timeout' in Test Step Settings or Test Plan Configuration if this delay is expected.", getTestData())); + } else if (e instanceof WebDriverException) { + try { + URL url = new URL(getTestData()); + HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); + httpURLConnection.setConnectTimeout(30 * 1000); + httpURLConnection.connect(); + int status_code = httpURLConnection.getResponseCode(); + + switch (status_code) { + case HttpStatus.SC_BAD_REQUEST: + setErrorCode(ErrorCodes.HTTP_BAD_REQUEST); + setErrorMessage(String.format("Cannot navigate to invalid URL \"%s\" - " + + "Please check the URL for invalid characters and also make sure it contains the correct prefix http:// or https://", getTestData())); + case HttpStatus.SC_UNAUTHORIZED: + setErrorCode(ErrorCodes.HTTP_UNAUTHORIZED); + setErrorMessage(String.format("The requested Web Page \"%s\" requires extra Authentication. " + + "Please pass the URL in the format 'https://<username>:<password>@<url>' by replacing the values for 'username', 'password' and 'url' " + + "if the page accepts Basic Authentication.

For more information, " + + "please refer - How to perform Basic Authentication for Web pages in Testsigma?", getTestData())); + case HttpStatus.SC_FORBIDDEN: + setErrorCode(ErrorCodes.HTTP_FORBIDDEN); + setErrorMessage(String.format("The requested Web Page \"%s\" requires extra Authentication. " + + "Please pass the URL in the format 'https://<username>:<password>@<url>' by replacing the values " + + "for 'username', 'password' and 'url' if the page accepts Basic Authentication.

For more information, " + + "please refer - How to perform Basic Authentication for Web pages in Testsigma?", getTestData())); + case HttpStatus.SC_NOT_FOUND: + setErrorCode(ErrorCodes.HTTP_NOT_FOUND); + setErrorMessage(String.format("The requested Web Page/Resource \"%s\" cannot be found on the Web Server. " + + "Please try the URL once in your Web Browser manually before trying again.", getTestData())); + case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: + setErrorCode(ErrorCodes.HTTP_PROXY_AUTHENTICATION_REQUIRED); + setErrorMessage(String.format("The requested Web Page \"%s\" requires Proxy Authentication. " + + "Please use 'Hybrid Execution' for running the Test on the corresponding URL.", getTestData())); + case HttpStatus.SC_INTERNAL_SERVER_ERROR: + setErrorCode(ErrorCodes.HTTP_INTERNAL_SERVER_ERROR); + setErrorMessage("The corresponding web server returned an unexpected error. Please check the URL once before trying again. " + + "If this page belongs to you, please contact the Admininstrator of this Domain/Web Application"); + default: + if (Integer.toString(status_code).startsWith("4")) { + setErrorCode(ErrorCodes.HTTP_GENERIC_CLIENT_SIDE_ERROR); + setErrorMessage(String.format("HTTP Error %s - The page returned a Client Side HTTP Error while trying to load the URL %s", + status_code, getTestData())); + } else if (Integer.toString(status_code).startsWith("5")) { + setErrorCode(ErrorCodes.HTTP_GENERIC_SERVER_SIDE_ERROR); + setErrorMessage(String.format("HTTP Error %s - The page returned a Server Side HTTP Error while trying to load the URL %s. " + + "Please contact the Server Administrator for more help.", status_code, getTestData())); + } + } + } catch (MalformedURLException malformurlex) { + setErrorCode(ErrorCodes.HTTP_MALFORMED_YRL_EXCEPTION); + setErrorMessage(String.format("Cannot navigate to invalid URL \"%s\" - " + + "Please check the URL for invalid characters and also make sure it contains the correct prefix http:// or https://", getTestData())); + } catch (SocketTimeoutException socktimeoutex) { + String errorMsg = "The requested Web Page/Resource \"%s\" took too long to respond and is not reachable currently. " + + "If you are trying to test a local Application and this is a local IP/Address, please use 'Hybrid Execution' for running the Test" + + ".

For more information, please refer - Why Cloud Test Environments can't access Locally hosted Applications?."; + setErrorCode(ErrorCodes.HTTP_SOCKET_EXCEPTION); + setErrorMessage(String.format(errorMsg, getTestData())); + } catch (UnknownHostException ex) { + setErrorCode(ErrorCodes.HTTP_UNKNOWN_HOST_EXCEPTION); + String errorMsg = "The requested Web Page/Resource \"%s\" not respond and is not reachable currently. " + + "If you are trying to test a local Application and this is a local IP/Address, please use 'Hybrid Execution' for running the Test" + + ".

For more information, please refer - Why Cloud Test Environments can't access Locally hosted Applications?."; + setErrorMessage(String.format(errorMsg, getTestData(), e.getMessage())); + } catch (IOException ioe) { + setErrorCode(ErrorCodes.HTTP_IO_EXCEPTION); + setErrorMessage(String.format("Cannot navigate to URL \"%s\" - due to below error
%s", getTestData(), e.getMessage())); + } catch (Throwable ex) { + setErrorMessage(String.format("Unable to load given URL \"%s\",please provide a valid URL.", getTestData())); + } + } else if (e instanceof MalformedURLException) { + setErrorCode(ErrorCodes.HTTP_MALFORMED_YRL_EXCEPTION); + setErrorMessage(String.format("Cannot navigate to invalid URL \"%s\" - " + + "Please check the URL for invalid characters and also make sure it contains the correct prefix http:// or https://", getTestData())); + } else if (e instanceof IOException) { + setErrorCode(ErrorCodes.HTTP_IO_EXCEPTION); + setErrorMessage(String.format("Cannot navigate to URL \"%s\" - due to below error
%s", getTestData(), e.getMessage())); + } else { + setErrorMessage(String.format("Unable to load given URL \"%s\",please verify the URL once.", getTestData())); + } + } +} diff --git a/automator/src/com/testsigma/automator/actions/web/store/StoreElementDimensionsAction.java b/automator/src/com/testsigma/automator/actions/web/store/StoreElementDimensionsAction.java new file mode 100644 index 000000000..49d4a04b2 --- /dev/null +++ b/automator/src/com/testsigma/automator/actions/web/store/StoreElementDimensionsAction.java @@ -0,0 +1,55 @@ +package com.testsigma.automator.actions.web.store; + +import com.testsigma.automator.actions.ElementAction; +import com.testsigma.automator.constants.NaturalTextActionConstants; +import com.testsigma.automator.exceptions.AutomatorException; +import org.openqa.selenium.Rectangle; + +public class StoreElementDimensionsAction extends ElementAction { + + protected static final String FAILURE_MESSAGE = "Unable to Perform Store Action due to " + + "invalid selectable test data. It accepts only xOffset/yOffset/height/width provided in the list"; + + private static final String SUCCESS_MESSAGE = "Successfully saved dimension in a run time variable.
%s=%s"; + + @Override + public void execute() throws Exception { + + findElement(); + Rectangle rect = getElement().getRect(); + + + String status = getTestData(); + int runTimeVarValue; + switch (status) { + case NaturalTextActionConstants.ELEMENT_xOFFSET: + runTimeVarValue = rect.getX(); + runtimeDataProvider.storeRuntimeVariable(getTestData(), runTimeVarValue + ""); + resultMetadata.put(getTestData(), runTimeVarValue); + setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData(), runTimeVarValue)); + break; + case NaturalTextActionConstants.ELEMENT_yOFFSET: + runTimeVarValue = rect.getY(); + runtimeDataProvider.storeRuntimeVariable(getTestData(), runTimeVarValue + ""); + resultMetadata.put(getTestData(), runTimeVarValue); + setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData(), runTimeVarValue)); + break; + case NaturalTextActionConstants.ELEMENT_HEIGHT: + runTimeVarValue = rect.getHeight(); + runtimeDataProvider.storeRuntimeVariable(getTestData(), runTimeVarValue + ""); + resultMetadata.put(getTestData(), runTimeVarValue); + setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData(), runTimeVarValue)); + break; + case NaturalTextActionConstants.ELEMENT_WIDTH: + runTimeVarValue = rect.getWidth(); + runtimeDataProvider.storeRuntimeVariable(getTestData(), runTimeVarValue + ""); + resultMetadata.put(getTestData(), runTimeVarValue); + setSuccessMessage(String.format(SUCCESS_MESSAGE, getTestData(), runTimeVarValue)); + break; + default: + setErrorMessage(FAILURE_MESSAGE); + throw new AutomatorException(FAILURE_MESSAGE); + } + } + +} diff --git a/automator/src/com/testsigma/automator/constants/AutomatorMessages.java b/automator/src/com/testsigma/automator/constants/AutomatorMessages.java index d392efd4d..fac6dd908 100644 --- a/automator/src/com/testsigma/automator/constants/AutomatorMessages.java +++ b/automator/src/com/testsigma/automator/constants/AutomatorMessages.java @@ -48,6 +48,8 @@ public class AutomatorMessages { public static final String KEYWORD_GO_TO = "Navigate to"; public static final String KEYWORD_SCREENSHOT = "Take screenshot with URL"; + + public static final String KEYWORD_ELEMENT_SCREENSHOT = "Capture"; public static final String EXCEPTION_DOWNLOAD_LOCAL_FILE = "There is no file with URL ?1"; final public static String INVALID_NUMBER_ARGUMENT = "Invalid integer provided to generate random test data string. Refer \"https://testsigma.com/docs/test-data/types/random/\" to know the valid integer range and learn more about random test data"; public static final String MSG_REST_INVALID_URL = "Invalid endpoint URL specified. Make sure the target host in the URL is valid and accessible. Also, the URL begins with HTTP or HTTPS"; diff --git a/automator/src/com/testsigma/automator/constants/NaturalTextActionConstants.java b/automator/src/com/testsigma/automator/constants/NaturalTextActionConstants.java index 4716e4811..8a6228af3 100644 --- a/automator/src/com/testsigma/automator/constants/NaturalTextActionConstants.java +++ b/automator/src/com/testsigma/automator/constants/NaturalTextActionConstants.java @@ -54,4 +54,9 @@ public class NaturalTextActionConstants { public final static String SET_INDEX = "Test Data Set Index"; public final static String SET_NAME = "Test Data Set Name"; public final static String RUNTIME_TEST_DATA_ID= "TestDataId"; + + public final static String ELEMENT_xOFFSET = "xOffset"; + public final static String ELEMENT_yOFFSET = "yOffset"; + public final static String ELEMENT_HEIGHT = "height"; + public final static String ELEMENT_WIDTH = "width"; } diff --git a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java index 6a809e990..ed585509d 100644 --- a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java +++ b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java @@ -18,6 +18,7 @@ import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.service.AddonService; import com.testsigma.automator.service.ObjectMapperService; +import com.testsigma.automator.suggestion.actions.SuggestionAction; import com.testsigma.automator.utilities.RuntimeDataProvider; import com.testsigma.automator.utilities.ScreenCaptureUtil; import com.testsigma.sdk.TestData; @@ -28,8 +29,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.logging.log4j.ThreadContext; +import org.openqa.selenium.By; import org.openqa.selenium.NoSuchSessionException; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.UnreachableBrowserException; import java.io.IOException; @@ -38,6 +41,8 @@ import java.sql.Timestamp; import java.util.*; +import static com.testsigma.automator.suggestion.actions.SuggestionAction.testCaseStepEntity; + @Log4j2 public abstract class TestcaseStepRunner { private static final String[] SKIP_SCREENSHOT_KEYWORDS = {"Close App", "Close all windows"}; @@ -666,6 +671,9 @@ private void takeScreenshot(WorkspaceType workspaceType, TestCaseStepEntity test } else if (testcaseStep.getAction() != null && testcaseStep.getAction().toLowerCase() .contains(AutomatorMessages.KEYWORD_SCREENSHOT.toLowerCase())) { screenshotType = 2; + } else if (testcaseStep.getAction() != null && testcaseStep.getAction().toLowerCase() + .contains(AutomatorMessages.KEYWORD_ELEMENT_SCREENSHOT.toLowerCase())) { + screenshotType = 3; } if (Arrays.asList(SKIP_SCREENSHOT_KEYWORDS).contains(testcaseStep.getAction())) { @@ -684,6 +692,10 @@ private void takeScreenshot(WorkspaceType workspaceType, TestCaseStepEntity test switch (workspaceType) { case WebApplication: + if (screenshotType == 3) { + testcaseStep.elementsMap.get("element").getLocatorValue(); + screenCaptureUtil.takeElementScreenShot(driver, testcaseStep, localFolderPath, screenshotS3URL); + } case MobileWeb: if (screenshotType == 1) { screenCaptureUtil.screenShotWithURL(localFolderPath, screenshotS3URL, driver); diff --git a/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java b/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java index b9c88d175..b412ffab6 100644 --- a/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java +++ b/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java @@ -2,11 +2,14 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.testsigma.automator.actions.ElementAction; import com.testsigma.automator.constants.EnvSettingsConstants; import com.testsigma.automator.constants.StorageConstants; +import com.testsigma.automator.entity.TestCaseStepEntity; import com.testsigma.automator.entity.TestDeviceSettings; import com.testsigma.automator.exceptions.TestsigmaScreenShotException; import com.testsigma.automator.runners.EnvironmentRunner; +import com.testsigma.automator.suggestion.actions.SuggestionAction; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.apache.commons.io.FileUtils; @@ -26,6 +29,8 @@ import java.util.List; import java.util.Map; +import static com.testsigma.automator.suggestion.actions.SuggestionAction.testCaseStepEntity; + @Log4j2 @RequiredArgsConstructor @@ -42,17 +47,36 @@ public ScreenCaptureUtil(List screenshots) { } - public void takeScreenShot(WebDriver webdriver, String loalFolderPath, String relativePath) throws Exception { + public void takeScreenShot(WebDriver webdriver, String localFolderPath, String relativePath) throws Exception { try { byte[] srcFile = ((TakesScreenshot) webdriver).getScreenshotAs(OutputType.BYTES); - saveScreenshotFile(srcFile, loalFolderPath, relativePath); + saveScreenshotFile(srcFile, localFolderPath, relativePath); } catch (WebDriverException e) { log.debug("Exception in taking screenshot using WebDriver. Details :: " + e.getMessage()); log.error(e.getMessage(), e); if (e instanceof UnhandledAlertException) { log.debug("The Exception is caused by Unhandled Alert."); - takeScreenShot(loalFolderPath, relativePath); + takeScreenShot(localFolderPath, relativePath); + } + } catch (Exception e) { + log.debug("Exception while Tacking screenshot" + e); + log.error(e.getMessage(), e); + } + } + + public void takeElementScreenShot(WebDriver driver, TestCaseStepEntity testCaseStep, String localFolderPath, String relativePath) throws Exception { + try { + testCaseStep.elementsMap.get("element").getFindByType(); + WebElement captureElement = driver.findElement(By.xpath(testCaseStepEntity.getLocatorValue())); + byte[] srcFile = captureElement.getScreenshotAs(OutputType.BYTES); + saveScreenshotFile(srcFile, localFolderPath, relativePath); + } catch (WebDriverException e) { + log.debug("Exception in taking screenshot of an element. Details :: " + e.getMessage()); + log.error(e.getMessage(), e); + if (e instanceof UnhandledAlertException) { + log.debug("The Exception is caused by Unhandled Alert."); + takeScreenShot(localFolderPath, relativePath); } } catch (Exception e) { log.debug("Exception while Tacking screenshot" + e); diff --git a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java index 1606aaf6b..381ba589f 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java @@ -17,11 +17,13 @@ import java.net.URL; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service @Log4j2 -public class PrivateGridDriverSettingsService extends DriverSettingsService { +public class PrivateGridDriverSettingsService extends DriverSettingsService { public static final String PLATFORM_WEB_URL = "/wd/hub"; @Autowired @@ -60,25 +62,45 @@ public void setWebCapabilities(TestDevice testDevice, TestPlanResult testPlanRes Integrations integrations, WebDriverSettingsDTO webDriverSettings) throws MalformedURLException, TestsigmaException { - List capabilities = new ArrayList<>(); +// List capabilities = new ArrayList<>(); +// +// /* PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testDevice.getTestPlan().getTestPlanLabType()); +// PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), testDevice.getTestPlan().getTestPlanLabType()); +// PlatformScreenResolution platformScreenResolution = platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), testDevice.getTestPlan().getTestPlanLabType()); +// */ +// +// capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM, testDevice.getPlatform())); +// if ((testDevice.getBrowserVersion()!=null && !testDevice.getBrowserVersion().equals("Not Available"))) +// capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION, testDevice.getBrowserVersion())); +// Browsers browser = Browsers.getBrowser(testDevice.getBrowser()); +// capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, TSCapabilityType.DEFAULT_RESOLUTION)); +// capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME)); +// capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION)); +// if (webDriverSettings.getWebDriverCapabilities() != null) +// webDriverSettings.getWebDriverCapabilities().addAll(capabilities); +// else +// webDriverSettings.setWebDriverCapabilities(capabilities); +// webDriverSettings.setWebDriverServerUrl(getRemoteDriverUrl(PLATFORM_WEB_URL, integrations)); - /* PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testDevice.getTestPlan().getTestPlanLabType()); - PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), testDevice.getTestPlan().getTestPlanLabType()); - PlatformScreenResolution platformScreenResolution = platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), testDevice.getTestPlan().getTestPlanLabType()); - */ + List capabilities = new ArrayList<>(); + capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM_NAME, testDevice.getPlatform())); capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM, testDevice.getPlatform())); + if ((testDevice.getBrowserVersion()!=null && !testDevice.getBrowserVersion().equals("Not Available"))) - capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION, testDevice.getBrowserVersion())); - Browsers browser = Browsers.getBrowser(testDevice.getBrowser()); - capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, TSCapabilityType.DEFAULT_RESOLUTION)); + capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION,testDevice.getBrowserVersion())); + capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, + TSCapabilityType.DEFAULT_RESOLUTION)); + // tsLabOptions.put(TSCapabilityType.NAME,testPlanResult.getTestPlan().getName()); + // tsLabOptions.put(TSCapabilityType.OS, platformOsVersion.getPlatform()); + //tsLabOptions.put(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion()); capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME)); capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION)); if (webDriverSettings.getWebDriverCapabilities() != null) webDriverSettings.getWebDriverCapabilities().addAll(capabilities); else webDriverSettings.setWebDriverCapabilities(capabilities); - webDriverSettings.setWebDriverServerUrl(getRemoteDriverUrl(PLATFORM_WEB_URL, integrations)); + webDriverSettings.setWebDriverServerUrl(getRemoteDriverUrl(PLATFORM_WEB_URL, integrations)); } diff --git a/server/src/main/java/com/testsigma/service/PrivateGridService.java b/server/src/main/java/com/testsigma/service/PrivateGridService.java index 69edb7f70..5c23ef203 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridService.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; @@ -28,15 +28,11 @@ import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; import org.json.JSONArray; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; @Service @@ -53,25 +49,48 @@ public class PrivateGridService { private Integrations applicationConfig; private void fetchBrowsersFromNode(String proxy, String gridURL) throws TestsigmaException { - HttpResponse response = httpClient.get(gridURL + "/grid/api/proxy?id=" + proxy, getHeaders(), new TypeReference() { - }); + List
headers = getHeaders(); + JSONObject query = new JSONObject(); + query.put("query", "{ nodesInfo { nodes { stereotypes } } }"); + HttpResponse response = httpClient.post(gridURL + "/graphql", + headers, query.toString(), new TypeReference<>() { + }); try { - JsonNode browsers = response.getResponseEntity().get("request").get("configuration").get("capabilities"); + JsonNode nodes = response.getResponseEntity().get("data").get("nodesInfo").get("nodes"); JSONArray validPlatforms = new JSONArray(); - for (JsonNode browser : browsers) { - ((ObjectNode) browser).put("browserName", StringUtils.capitalize(browser.get("browserName").asText().toLowerCase().replaceAll("\\s", ""))); - ((ObjectNode) browser).put("platform", StringUtils.capitalize(browser.get("platform").asText().toLowerCase().replaceAll("\\s", ""))); - if (OSBrowserType.getBrowserEnumValueIfExists(browser.get("browserName").asText())==null){ - continue; + JSONObject browserDetails; + if (!nodes.isEmpty()) { + for (JsonNode node : nodes) { + String stereotypes = node.get("stereotypes").asText().replaceAll("\n", ""); + JSONArray nodeStereotypes = new JSONArray(stereotypes); + for (int i = 0; i < nodeStereotypes.length(); i++) { + JSONObject nodeDetails = (JSONObject) nodeStereotypes.get(i); + JSONObject stereotype = (JSONObject) nodeDetails.get("stereotype"); + browserDetails = new JSONObject(); + browserDetails.put("browserName", StringUtils.capitalize(stereotype.get("browserName").toString().toLowerCase().replaceAll("\\s", ""))); + browserDetails.put("maxInstances",Integer.parseInt(nodeDetails.get("slots").toString())); +// if (OSBrowserType.getBrowserEnumValueIfExists(String.valueOf(browserDetails.get("browserName")))==null){ +// continue; +// } + if (String.valueOf(stereotype.get("platformName")).contains("Win") || String.valueOf(stereotype.get("platformName")).contains("WIN")) + { + browserDetails.put("platform", "Windows"); + browserDetails.put("platformName", "Windows"); + } else + { + browserDetails.put("platform", StringUtils.capitalize(stereotype.get("platformName").toString().toLowerCase().replaceAll("\\s", ""))); + browserDetails.put("platformName", StringUtils.capitalize(stereotype.get("platformName").toString().toLowerCase().replaceAll("\\s", ""))); + } + validPlatforms.put(browserDetails); + } + } } - if (browser.get("platform").asText().contains("Win") || browser.get("platform").asText().contains("WIN")) - ((ObjectNode) browser).put("platform", "Windows"); - validPlatforms.put(browser); - } ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - PrivateGridBrowserRequest[] browsersList = mapper.convertValue(validPlatforms, PrivateGridBrowserRequest[].class); + PrivateGridBrowserRequest[] browsersList = new ObjectMapperService().parseJson(validPlatforms.toString(), PrivateGridBrowserRequest[].class); +// PrivateGridBrowserRequest[] browsersList = mapper.convertValue(validPlatforms, PrivateGridBrowserRequest[].class); PrivateGridNodeRequest request = new PrivateGridNodeRequest(); request.setNodeName(proxy); request.setGridURL(gridURL); @@ -91,29 +110,32 @@ private void fetchBrowsersFromNode(String proxy, String gridURL) throws Testsigm } public List ParseProxyIds(String gridUrl) throws TestsigmaException { - HttpResponse response = httpClient.get(gridUrl + "/grid/console", getHeaders(), new TypeReference() { - }); - Document doc = Jsoup.parse(response.toString()); - Elements proxies = doc.select("p.proxyid"); - // "((https?|ftp|gopher|telnet|file):((//)|(\\\\))+[\\w\\d:#@%/;$()~_?\\+-=\\\\\\.&]*)"; - String urlRegex = "\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"; + List
headers = getHeaders(); + JSONObject query = new JSONObject(); + query.put("query", "{ nodesInfo { nodes { uri } } }"); + HttpResponse response = httpClient.post(gridUrl + "/graphql", + headers, query.toString(), new TypeReference<>() { + }); + + JsonNode proxies = response.getResponseEntity().get("data").get("nodesInfo").get("nodes"); List parsedURLs = new ArrayList(); try { - Pattern pattern = Pattern.compile(urlRegex, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(proxies.text()); - while (matcher.find()) { - String URL = proxies.text().substring(matcher.start(0), matcher.end(0)); - if (!parsedURLs.contains(URL)) { - parsedURLs.add(URL); - this.fetchBrowsersFromNode(URL, gridUrl); + if (!proxies.isEmpty()) { + for (JsonNode proxy : proxies) { + String url = proxy.get("uri").asText(); + if (!parsedURLs.contains(url)) { + parsedURLs.add(url); + this.fetchBrowsersFromNode(url, gridUrl); + } + } + if (!(parsedURLs.size() > 0)) { + log.error(" No URL found with the given regex in the response message."); } } - if (!(parsedURLs.size() > 0)) { - log.error(" No URL found with the given regex in the response message."); - } - } catch (Exception e) { + } + catch (Exception e) { log.error(e.getMessage(), e); if (e instanceof TestsigmaException) throw new TestsigmaException(e.getMessage()); diff --git a/server/src/main/resources/db/bootstrap/V207__bootstrap_natural_text_actions.sql b/server/src/main/resources/db/bootstrap/V207__bootstrap_natural_text_actions.sql index 6638b841f..8ec188657 100644 --- a/server/src/main/resources/db/bootstrap/V207__bootstrap_natural_text_actions.sql +++ b/server/src/main/resources/db/bootstrap/V207__bootstrap_natural_text_actions.sql @@ -590,5 +590,14 @@ INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `dat INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`) VALUES (10218, 'MobileWeb', 'Write value ${test-data} to ${test-data-profile} column ${parameter}', '{\"test-data\":{\"test-data\":\"test-data\",\"test-data-profile\":\"test-data-profile\", \"parameter\":\"parameter\"}}', 'updateTestDataProfileParameter', 'com.testsigma.automator.actions.web.store.UpdateTestDataParamWithTestDataAction', 'store', 1104, 10218, 20180, 40035, '2022-12-02 14:54:08', '2022-12-02 14:54:08', NULL); INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`) VALUES (20180, 'AndroidNative', 'Write value ${test-data} to ${test-data-profile} column ${parameter}', '{\"test-data\":{\"test-data\":\"test-data\",\"test-data-profile\":\"test-data-profile\", \"parameter\":\"parameter\"}}', 'updateTestDataProfileParameter', 'com.testsigma.automator.actions.web.store.UpdateTestDataParamWithTestDataAction', 'store', 1104, 10218, 20180, 40035, '2022-12-02 14:54:08', '2022-12-02 14:54:08', NULL); INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`) VALUES (40035, 'IOSNative', 'Write value ${test-data} to ${test-data-profile} column ${parameter}', '{\"test-data\":{\"test-data\":\"test-data\",\"test-data-profile\":\"test-data-profile\", \"parameter\":\"parameter\"}}', 'updateTestDataProfileParameter', 'com.testsigma.automator.actions.web.store.UpdateTestDataParamWithTestDataAction', 'store', 1104, 10218, 20180, 40035, '2022-12-02 14:54:08', '2022-12-02 14:54:08', NULL); + +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (1112,'WebApplication','Capture #{element}','{"test-data":null,"element":"\\\\#{.*?}","attribute":null,"from-element":null,"to-element":null}','elementScreenshot','com.testsigma.automator.actions.web.generic.ElementScreenshotAction','verify,',1112,10228,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (10228,'MobileWeb','Capture #{element}','{"test-data":null,"element":"\\\\#{.*?}","attribute":null,"from-element":null,"to-element":null}','elementScreenshot','com.testsigma.automator.actions.mobile.mobileweb.generic.ElementScreenshotSnippet','verify,',1112,10228,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); + +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (1113,'WebApplication','Open new browser window and navigate to ${test-data}','{"test-data":{"test-data":"test-data"},"element":null,"attribute":null,"from-element":null,"to-element":null}','navigateTo','com.testsigma.automator.actions.web.generic.OpenNewBrowserWindowAction','navigate',1113,10229,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (10229,'MobileWeb','Open new browser window and navigate to ${test-data}','{"test-data":{"test-data":"test-data"},"element":null,"attribute":null,"from-element":null,"to-element":null}','navigateTo','com.testsigma.automator.actions.mobile.mobileweb.generic.OpenNewBrowserWindowSnippet','navigate',1113,10229,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); + +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (1114,'WebApplication','Store ${test-data} of an #{element} into runtime variable @{attribute}','{"test-data":{"test-data":"xOffset/yOffset/height/width"},"ui-identifier":"\\\\#{.*?}","attribute":"\\\\@{.*?}"}','store','com.testsigma.automator.actions.web.store.StoreElementDimensionsAction','store',1114,10230,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) VALUES (10230,'MobileWeb','Store ${test-data} of an #{element} into runtime variable @{attribute}','{"test-data":{"test-data":"xOffset/yOffset/height/width"},"ui-identifier":"\\\\#{.*?}","attribute":"\\\\@{.*?}"}','store','com.testsigma.automator.actions.mobile.mobileweb.store.StoreElementDimensionSnippet','store',1114,10230,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); /*!40000 ALTER TABLE `natural_text_actions` ENABLE KEYS */; UNLOCK TABLES; \ No newline at end of file diff --git a/server/src/main/resources/db/migration/V65__selenium4_nlp.sql b/server/src/main/resources/db/migration/V65__selenium4_nlp.sql new file mode 100644 index 000000000..5e67321eb --- /dev/null +++ b/server/src/main/resources/db/migration/V65__selenium4_nlp.sql @@ -0,0 +1,14 @@ +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (1112,'WebApplication','Capture #{element}','{"test-data":null,"element":"\\\\#{.*?}","attribute":null,"from-element":null,"to-element":null}','elementScreenshot','com.testsigma.automator.actions.web.generic.ElementScreenshotAction','verify,',1112,10228,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (10228,'MobileWeb','Capture #{element}','{"test-data":null,"element":"\\\\#{.*?}","attribute":null,"from-element":null,"to-element":null}','elementScreenshot','com.testsigma.automator.actions.mobile.mobileweb.generic.ElementScreenshotSnippet','verify,',1112,10228,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); + +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (1113,'WebApplication','Open new browser window and navigate to ${test-data}','{"test-data":{"test-data":"test-data"},"element":null,"attribute":null,"from-element":null,"to-element":null}','navigateTo','com.testsigma.automator.actions.web.generic.OpenNewBrowserWindowAction','navigate',1113,10229,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (10229,'MobileWeb','Open new browser window and navigate to ${test-data}','{"test-data":{"test-data":"test-data"},"element":null,"attribute":null,"from-element":null,"to-element":null}','navigateTo','com.testsigma.automator.actions.mobile.mobileweb.generic.OpenNewBrowserWindowSnippet','navigate',1113,10229,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); + +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (1114,'WebApplication','Store ${test-data} of an #{element} into runtime variable @{attribute}','{"test-data":{"test-data":"xOffset/yOffset/height/width"},"ui-identifier":"\\\\#{.*?}","attribute":"\\\\@{.*?}"}','store','com.testsigma.automator.actions.web.store.StoreElementDimensionsAction','store',1114,10230,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); +INSERT INTO `natural_text_actions` (`id`, `workspace_type`, `natural_text`, `data`, `display_name`, `snippet_class`, `action`, `import_to_web`, `import_to_mobile_web`, `import_to_android_native`, `import_to_ios_native`, `created_date`, `updated_date`, `allowed_values`, `condition_type`) +VALUES (10230,'MobileWeb','Store ${test-data} of an #{element} into runtime variable @{attribute}','{"test-data":{"test-data":"xOffset/yOffset/height/width"},"ui-identifier":"\\\\#{.*?}","attribute":"\\\\@{.*?}"}','store','com.testsigma.automator.actions.mobile.mobileweb.store.StoreElementDimensionSnippet','store',1114,10230,0,0,'2023-05-05 17:10:03','2023-05-05 17:10:03',NULL,NULL); \ No newline at end of file From 334a08a51afd3ae8a3c4310d8e147c72b24f2cb7 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Fri, 26 May 2023 14:07:53 +0530 Subject: [PATCH 28/41] (feat): grid fixes --- .../PrivateGridDriverSettingsService.java | 41 +++++-------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java index 381ba589f..2b4b9abe0 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java @@ -61,41 +61,20 @@ public URL getRemoteDriverUrl(String url, Integrations integrations) public void setWebCapabilities(TestDevice testDevice, TestPlanResult testPlanResult, Integrations integrations, WebDriverSettingsDTO webDriverSettings) - throws MalformedURLException, TestsigmaException { -// List capabilities = new ArrayList<>(); -// -// /* PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testDevice.getTestPlan().getTestPlanLabType()); -// PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), testDevice.getTestPlan().getTestPlanLabType()); -// PlatformScreenResolution platformScreenResolution = platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), testDevice.getTestPlan().getTestPlanLabType()); -// */ -// -// capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM, testDevice.getPlatform())); -// if ((testDevice.getBrowserVersion()!=null && !testDevice.getBrowserVersion().equals("Not Available"))) -// capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION, testDevice.getBrowserVersion())); -// Browsers browser = Browsers.getBrowser(testDevice.getBrowser()); -// capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, TSCapabilityType.DEFAULT_RESOLUTION)); -// capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME)); -// capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION)); -// if (webDriverSettings.getWebDriverCapabilities() != null) -// webDriverSettings.getWebDriverCapabilities().addAll(capabilities); -// else -// webDriverSettings.setWebDriverCapabilities(capabilities); -// webDriverSettings.setWebDriverServerUrl(getRemoteDriverUrl(PLATFORM_WEB_URL, integrations)); + throws MalformedURLException { List capabilities = new ArrayList<>(); + Map testsigmaOptions = new HashMap<>(); capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM_NAME, testDevice.getPlatform())); - capabilities.add(new WebDriverCapability(TSCapabilityType.PLATFORM, testDevice.getPlatform())); - - if ((testDevice.getBrowserVersion()!=null && !testDevice.getBrowserVersion().equals("Not Available"))) - capabilities.add(new WebDriverCapability(TSCapabilityType.VERSION,testDevice.getBrowserVersion())); - capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, - TSCapabilityType.DEFAULT_RESOLUTION)); - // tsLabOptions.put(TSCapabilityType.NAME,testPlanResult.getTestPlan().getName()); - // tsLabOptions.put(TSCapabilityType.OS, platformOsVersion.getPlatform()); - //tsLabOptions.put(TSCapabilityType.OS_VERSION, platformOsVersion.getPlatformVersion()); - capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME)); - capabilities.add(new WebDriverCapability(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION)); + testsigmaOptions.put(TSCapabilityType.TESTSIGMA_LAB_KEY_SCREEN_RESOLUTION, + TSCapabilityType.DEFAULT_RESOLUTION); + testsigmaOptions.put(TSCapabilityType.NAME,testPlanResult.getTestPlan().getName()); + testsigmaOptions.put(TSCapabilityType.KEY_MAX_IDLE_TIME, TSCapabilityType.MAX_IDLE_TIME); + testsigmaOptions.put(TSCapabilityType.KEY_MAX_DURATION, TSCapabilityType.MAX_DURATION); + + capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS, testsigmaOptions)); + if (webDriverSettings.getWebDriverCapabilities() != null) webDriverSettings.getWebDriverCapabilities().addAll(capabilities); else From 42b88e07e91228c415496e5b79c9c589d2872f71 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Fri, 26 May 2023 18:15:24 +0530 Subject: [PATCH 29/41] fixes for grid --- .../actions/web/generic/OpenNewBrowserWindowAction.java | 1 - .../main/java/com/testsigma/service/IntegrationsService.java | 2 +- .../testsigma/service/PrivateGridDriverSettingsService.java | 3 +-- .../main/java/com/testsigma/service/PrivateGridService.java | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java b/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java index 0e3602b5b..80f593943 100644 --- a/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java +++ b/automator/src/com/testsigma/automator/actions/web/generic/OpenNewBrowserWindowAction.java @@ -27,7 +27,6 @@ protected void execute() throws Exception { protected void handleException(Exception e) { super.handleException(e); if (e instanceof UnreachableBrowserException || e instanceof NoSuchSessionException) { - //These two exception types are already handled in super class. } else if (e instanceof TimeoutException) { setErrorMessage(String.format("The Web Page with URL \"%s\" failed to load within the configured page load timeout duration. " + "Please increase the 'page load timeout' in Test Step Settings or Test Plan Configuration if this delay is expected.", getTestData())); diff --git a/server/src/main/java/com/testsigma/service/IntegrationsService.java b/server/src/main/java/com/testsigma/service/IntegrationsService.java index 76df952d5..4abec86c1 100644 --- a/server/src/main/java/com/testsigma/service/IntegrationsService.java +++ b/server/src/main/java/com/testsigma/service/IntegrationsService.java @@ -73,7 +73,7 @@ public Integrations find(Long id) * @return */ public void destroy(Long id) throws IntegrationNotFoundException { - Optional config = integrationsRepository.findByWorkspaceId(id); + Optional config = integrationsRepository.findById(id); if (!config.isPresent()) { throw new IntegrationNotFoundException("EXTERNAL APPLICATION CONFIG NOT FOUND"); } diff --git a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java index 2b4b9abe0..de565a23e 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridDriverSettingsService.java @@ -7,7 +7,6 @@ import com.testsigma.exception.TestsigmaException; import com.testsigma.model.*; import lombok.extern.log4j.Log4j2; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.WebApplicationContext; @@ -23,7 +22,7 @@ @Service @Log4j2 -public class PrivateGridDriverSettingsService extends DriverSettingsService { +public class PrivateGridDriverSettingsService extends DriverSettingsService { public static final String PLATFORM_WEB_URL = "/wd/hub"; @Autowired diff --git a/server/src/main/java/com/testsigma/service/PrivateGridService.java b/server/src/main/java/com/testsigma/service/PrivateGridService.java index 5c23ef203..bf0580e2a 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridService.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; @@ -87,7 +86,6 @@ private void fetchBrowsersFromNode(String proxy, String gridURL) throws Testsigm } ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); PrivateGridBrowserRequest[] browsersList = new ObjectMapperService().parseJson(validPlatforms.toString(), PrivateGridBrowserRequest[].class); // PrivateGridBrowserRequest[] browsersList = mapper.convertValue(validPlatforms, PrivateGridBrowserRequest[].class); From ab37e0281bd7ce24716058bb111a500b695d5154 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Mon, 29 May 2023 14:36:55 +0530 Subject: [PATCH 30/41] (feat): Element level screenshot --- .../automator/runners/TestcaseStepRunner.java | 10 +++------- .../automator/utilities/ScreenCaptureUtil.java | 16 ++++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java index ed585509d..7150baa77 100644 --- a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java +++ b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java @@ -12,13 +12,11 @@ import com.testsigma.automator.constants.EnvSettingsConstants; import com.testsigma.automator.constants.NaturalTextActionConstants; import com.testsigma.automator.constants.AutomatorMessages; -import com.testsigma.automator.constants.TestStepConditionType; import com.testsigma.automator.drivers.DriverManager; import com.testsigma.automator.entity.*; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.service.AddonService; import com.testsigma.automator.service.ObjectMapperService; -import com.testsigma.automator.suggestion.actions.SuggestionAction; import com.testsigma.automator.utilities.RuntimeDataProvider; import com.testsigma.automator.utilities.ScreenCaptureUtil; import com.testsigma.sdk.TestData; @@ -29,10 +27,8 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.logging.log4j.ThreadContext; -import org.openqa.selenium.By; import org.openqa.selenium.NoSuchSessionException; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.UnreachableBrowserException; import java.io.IOException; @@ -41,7 +37,6 @@ import java.sql.Timestamp; import java.util.*; -import static com.testsigma.automator.suggestion.actions.SuggestionAction.testCaseStepEntity; @Log4j2 public abstract class TestcaseStepRunner { @@ -693,7 +688,6 @@ private void takeScreenshot(WorkspaceType workspaceType, TestCaseStepEntity test switch (workspaceType) { case WebApplication: if (screenshotType == 3) { - testcaseStep.elementsMap.get("element").getLocatorValue(); screenCaptureUtil.takeElementScreenShot(driver, testcaseStep, localFolderPath, screenshotS3URL); } case MobileWeb: @@ -702,7 +696,9 @@ private void takeScreenshot(WorkspaceType workspaceType, TestCaseStepEntity test } else if (screenshotType == 2) { screenCaptureUtil.fullPageScreenshotWithURL(localFolderPath, screenshotS3URL, driver); - } else { + } else if (screenshotType == 3) { + screenCaptureUtil.takeElementScreenShot(driver, testcaseStep, localFolderPath, screenshotS3URL); + } else { screenCaptureUtil.takeScreenShot(driver, localFolderPath, screenshotS3URL); } break; diff --git a/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java b/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java index b412ffab6..79575d267 100644 --- a/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java +++ b/automator/src/com/testsigma/automator/utilities/ScreenCaptureUtil.java @@ -2,14 +2,14 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.testsigma.automator.actions.ElementAction; +import com.testsigma.automator.actions.ElementSearchCriteria; +import com.testsigma.automator.actions.FindByType; import com.testsigma.automator.constants.EnvSettingsConstants; import com.testsigma.automator.constants.StorageConstants; import com.testsigma.automator.entity.TestCaseStepEntity; import com.testsigma.automator.entity.TestDeviceSettings; import com.testsigma.automator.exceptions.TestsigmaScreenShotException; import com.testsigma.automator.runners.EnvironmentRunner; -import com.testsigma.automator.suggestion.actions.SuggestionAction; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import org.apache.commons.io.FileUtils; @@ -29,8 +29,6 @@ import java.util.List; import java.util.Map; -import static com.testsigma.automator.suggestion.actions.SuggestionAction.testCaseStepEntity; - @Log4j2 @RequiredArgsConstructor @@ -67,10 +65,12 @@ public void takeScreenShot(WebDriver webdriver, String localFolderPath, String r public void takeElementScreenShot(WebDriver driver, TestCaseStepEntity testCaseStep, String localFolderPath, String relativePath) throws Exception { try { - testCaseStep.elementsMap.get("element").getFindByType(); - WebElement captureElement = driver.findElement(By.xpath(testCaseStepEntity.getLocatorValue())); - byte[] srcFile = captureElement.getScreenshotAs(OutputType.BYTES); - saveScreenshotFile(srcFile, localFolderPath, relativePath); + FindByType findByType = testCaseStep.elementsMap.get("element").getFindByType(); + String byValue = testCaseStep.elementsMap.get("element").getLocatorValue(); + ElementSearchCriteria elementSearchCriteria = new ElementSearchCriteria(findByType, byValue); + List elements = driver.findElements(elementSearchCriteria.getBy()); + byte[] srcFile = elements.get(0).getScreenshotAs(OutputType.BYTES); + saveScreenshotFile(srcFile, localFolderPath, relativePath); } catch (WebDriverException e) { log.debug("Exception in taking screenshot of an element. Details :: " + e.getMessage()); log.error(e.getMessage(), e); From 8c0dd8d331374b1076bcc09463c97fa5286159c8 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Fri, 2 Jun 2023 12:47:15 +0530 Subject: [PATCH 31/41] (feat): Driver Manager --- .../agent/mobile/DeviceContainer.java | 2 - .../agent/services/DriverSessionsService.java | 26 +-- automator/pom.xml | 8 + .../drivers/DriversUpdateService.java | 165 ------------------ .../automator/drivers/web/ChromeDriver.java | 17 +- .../automator/drivers/web/EdgeDriver.java | 16 +- .../automator/drivers/web/FirefoxDriver.java | 16 +- .../automator/drivers/web/SafariDriver.java | 15 ++ .../automator/drivers/web/WebDriver.java | 6 + .../automator/runners/EnvironmentRunner.java | 4 - 10 files changed, 75 insertions(+), 200 deletions(-) delete mode 100644 automator/src/com/testsigma/automator/drivers/DriversUpdateService.java diff --git a/agent/src/main/java/com/testsigma/agent/mobile/DeviceContainer.java b/agent/src/main/java/com/testsigma/agent/mobile/DeviceContainer.java index 508cbe502..444e0af2a 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/DeviceContainer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/DeviceContainer.java @@ -19,7 +19,6 @@ import com.testsigma.agent.mappers.MobileDeviceMapper; import com.fasterxml.jackson.core.type.TypeReference; import com.testsigma.automator.AutomatorConfig; -import com.testsigma.automator.drivers.DriversUpdateService; import com.testsigma.automator.entity.Browsers; import com.testsigma.automator.entity.OsBrowserType; import com.testsigma.automator.exceptions.AutomatorException; @@ -97,7 +96,6 @@ public void syncBrowserDrivers(MobileDevice mobileDevice) { Browsers browser = OsBrowserType.getBrowserType(browserType); String driverPath = AutomatorConfig.getInstance().getAppBridge().getDriverExecutablePath(browser.getKey(), browserVersion); - new DriversUpdateService().syncBrowserDriver(browserType, browserVersion, driverPath); } catch (AutomatorException e) { log.error(e.getMessage(), e); } diff --git a/agent/src/main/java/com/testsigma/agent/services/DriverSessionsService.java b/agent/src/main/java/com/testsigma/agent/services/DriverSessionsService.java index 1342a6fb2..2fafd04c7 100644 --- a/agent/src/main/java/com/testsigma/agent/services/DriverSessionsService.java +++ b/agent/src/main/java/com/testsigma/agent/services/DriverSessionsService.java @@ -136,40 +136,22 @@ private void setRemoteServerURL(TestsigmaDriver testsigmaDriver, DriverSessionRe } private void handleLocalDevice(List caps, DriverSessionRequest driverSessionRequest) - throws TestsigmaException, AutomatorException { + throws TestsigmaException, AutomatorException { if (driverSessionRequest.getExecutionLabType().equals(ExecutionLabType.Hybrid)) { - appendChromeDriverExecutable(caps, driverSessionRequest); if (driverSessionRequest.getWorkspaceType() == WorkspaceType.IOSNative) { setupIosDevice(caps, driverSessionRequest); } } } - - private void appendChromeDriverExecutable(List caps, DriverSessionRequest driverSessionRequest) - throws TestsigmaException { - MobileDevice device = deviceContainer.getDevice(driverSessionRequest.getUniqueId()); - if (device.getBrowserList() != null && device.getBrowserList().size() > 0) { - AgentBrowser browser = device.getBrowserList().get(0); - File chromePath = driverExecutableExists(Browsers.GoogleChrome.getKey(), - browser.getMajorVersion() + ""); - if (chromePath != null) { - WebDriverCapability cap = new WebDriverCapability(TSCapabilityType.CHROME_DRIVER_EXECUTABLE, chromePath.getAbsolutePath()); - caps.add(cap); - } else { - log.warn("Chrome Driver is not yet downloaded.. please try after some time"); - } - } - } - public void setupIosDevice(List caps, DriverSessionRequest driverSessionRequest) - throws TestsigmaException, AutomatorException { + throws TestsigmaException, AutomatorException { MobileDevice device = deviceContainer.getDevice(driverSessionRequest.getUniqueId()); iosDeviceService.setupWda(device); WebDriverCapability bundleIdCapability = caps.stream().filter(cap -> cap.getCapabilityName() - .equals(TSCapabilityType.BUNDLE_ID)).findFirst().orElse(null); + .equals(TSCapabilityType.BUNDLE_ID)).findFirst().orElse(null); if ((bundleIdCapability == null) || StringUtils.isBlank((String) bundleIdCapability.getCapabilityValue())) { WebDriverCapability appCapability = caps.stream().filter(cap -> cap.getCapabilityName() - .equals(MobileCapabilityType.APP)).findFirst().orElse(null); + .equals(MobileCapabilityType.APP)).findFirst().orElse(null); AppPathType appPathType = driverSessionRequest.getApplicationPathType(); if ((appCapability != null) && appPathType != AppPathType.APP_DETAILS) { caps.remove(appCapability); diff --git a/automator/pom.xml b/automator/pom.xml index 00fd3fb6d..5b000c2ac 100644 --- a/automator/pom.xml +++ b/automator/pom.xml @@ -316,6 +316,14 @@ 5.3.20 compile + + + + io.github.bonigarcia + webdrivermanager + 5.3.3 + + diff --git a/automator/src/com/testsigma/automator/drivers/DriversUpdateService.java b/automator/src/com/testsigma/automator/drivers/DriversUpdateService.java deleted file mode 100644 index 49785a348..000000000 --- a/automator/src/com/testsigma/automator/drivers/DriversUpdateService.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.testsigma.automator.drivers; - -import com.testsigma.automator.entity.*; -import com.testsigma.automator.exceptions.AutomatorException; -import com.testsigma.automator.utilities.OsUtil; -import com.testsigma.automator.utilities.PathUtil; -import lombok.extern.log4j.Log4j2; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -@Log4j2 -public class DriversUpdateService { - public static final String BROWSER_STR = "browser"; - public static final String VERSION_STR = "version"; - private final String driversFolderPath; - private final String osType; - - public DriversUpdateService() { - driversFolderPath = PathUtil.getInstance().getDriversPath(); - osType = new OsUtil().getOsType(); - } - - public static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException { - File destFile = new File(destinationDir, zipEntry.getName()); - - String destDirPath = destinationDir.getCanonicalPath(); - String destFilePath = destFile.getCanonicalPath(); - - if (!destFilePath.startsWith(destDirPath + File.separator)) { - throw new IOException("Entry is outside of the target dir: " + zipEntry.getName()); - } - - return destFile; - } - - public void syncBrowserDriver(TestDeviceEntity testDeviceEntity) throws AutomatorException { - if (testDeviceEntity.getExecutionLabType() == ExecutionLabType.Hybrid) { - log.info("Trying to check and sync browser driver for environment - " + testDeviceEntity.getId()); - Map browserDetailsMap = getBrowserDetailsFromEnvironment(testDeviceEntity.getEnvSettings()); - log.info(String.format("Retrieved Browser Details - Name: %s - Version: %s", browserDetailsMap.get(BROWSER_STR), - browserDetailsMap.get(VERSION_STR))); - if (StringUtils.isBlank(browserDetailsMap.get(BROWSER_STR))) { - return; - } - OsBrowserType browserType = OsBrowserType.getOsBrowserType(browserDetailsMap.get(BROWSER_STR)); - String browserVersion = browserDetailsMap.get(VERSION_STR); - String driverPath = testDeviceEntity.getEnvSettings().getHybridBrowserDriverPath(); - syncBrowserDriver(browserType, browserVersion, driverPath); - } else { - log.info(String.format("Execution Lab Type <%s> doesn't require driver sync. Skipping it", - testDeviceEntity.getExecutionLabType())); - } - } - - public void syncBrowserDriver(OsBrowserType browserType, String browserVersion, String driverPath) - throws AutomatorException { - log.info(String.format("Trying to check and sync browser - %s - %s - %s", browserType, browserVersion, - driverPath)); - try { - if (!isDriverExecutableExists(driverPath)) { - log.info(String.format("%s : %s - Browser driver does not exist. downloading it", browserType, browserVersion)); - updateDriver(browserType, browserVersion); - log.info(String.format("%s : %s - Finished downloading the browser driver", browserType, browserVersion)); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - throw new AutomatorException(e.getMessage(), e); - } - } - - private Map getBrowserDetailsFromEnvironment(TestDeviceSettings envSettings) { - Map browserDetails = new HashMap<>(); - String browser = envSettings.getBrowser(); - String browserVersion = envSettings.getBrowserVersion(); - browserDetails.put(BROWSER_STR, browser); - browserDetails.put(VERSION_STR, browserVersion); - return browserDetails; - } - - private void updateDriver(OsBrowserType browserName, String versionStr) - throws IOException { - if (browserName == OsBrowserType.Chrome) { - downloadAndCopyDriverFile(Browsers.GoogleChrome, versionStr); - } else if (browserName == OsBrowserType.Firefox) { - downloadAndCopyDriverFile(Browsers.MozillaFirefox, versionStr); - } else if (browserName == OsBrowserType.Edge) { - downloadAndCopyDriverFile(Browsers.MicrosoftEdge, versionStr); - } else if (browserName == OsBrowserType.Safari) { - } - } - - private void downloadAndCopyDriverFile(Browsers browser, String majorVersion) throws IOException { - String browserVersion = Float.parseFloat(majorVersion) + ""; - String zipFileName = browserVersion.replace(".", "_") + ".zip"; - String driverDownloadUrl = getDriverDownloadURL(osType, browser, zipFileName); - File driverLocalPath = Paths.get(driversFolderPath, browser.getBrowserFolderName(), zipFileName).toFile(); - log.info(String.format("Copying Driver File From %s to %s", driverDownloadUrl, driverLocalPath)); - FileUtils.copyURLToFile(new URL(driverDownloadUrl), driverLocalPath, (60 * 1000), (60 * 1000)); - File driverVersionFolder = Paths.get(driversFolderPath, browser.getBrowserFolderName(), browserVersion).toFile(); - unzipDriver(driverLocalPath, driverVersionFolder); - } - - private boolean isDriverExecutableExists(String path) { - String dirPath = driversFolderPath + path; - log.info("Verifying if driver version folder exists: " + dirPath); - File browserVersionDirFile = new File(dirPath); - if (browserVersionDirFile.exists()) { - File driverFile = new File(browserVersionDirFile.getAbsolutePath()); - return driverFile.exists() && driverFile.isFile(); - } - return false; - } - - private String getDriverDownloadURL(String osName, Browsers browser, String zipFileName) { - return String.format("http://drivers.testsigma.com/%s/%s/%s", osName, browser.getBrowserFolderName(), - zipFileName); - } - - private void unzipDriver(File sourceZipFile, File destinationFolder) throws IOException { - File destDir = new File(destinationFolder.getAbsolutePath()); - byte[] buffer = new byte[1024]; - ZipInputStream zis = new ZipInputStream(new FileInputStream(sourceZipFile)); - ZipEntry zipEntry = zis.getNextEntry(); - while (zipEntry != null) { - File newFile = newFile(destDir, zipEntry); - if (zipEntry.isDirectory()) { - if (!newFile.isDirectory() && !newFile.mkdirs()) { - throw new IOException("Failed to create directory " + newFile); - } - } else { - // fix for Windows-created archives - File parent = newFile.getParentFile(); - if (!parent.isDirectory() && !parent.mkdirs()) { - throw new IOException("Failed to create directory " + parent); - } - - // write file content - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); - if (osType.equalsIgnoreCase("mac") || osType.equalsIgnoreCase("linux")) { - Runtime.getRuntime().exec("chmod u+x " + newFile.getAbsolutePath()); - } - } - zipEntry = zis.getNextEntry(); - } - zis.closeEntry(); - zis.close(); - sourceZipFile.delete(); - } -} diff --git a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java index 52edc26a6..826aacef5 100644 --- a/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/ChromeDriver.java @@ -1,6 +1,5 @@ package com.testsigma.automator.drivers.web; -import com.testsigma.automator.constants.TSCapabilityType; import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.utilities.PathUtil; @@ -10,6 +9,7 @@ import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; +import io.github.bonigarcia.wdm.WebDriverManager; import java.io.File; import java.net.MalformedURLException; @@ -48,8 +48,6 @@ protected void setTestsigmaLabCapabilities() throws AutomatorException { @Override public void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); - System.setProperty(TSCapabilityType.BROWSER_DRIVER_PROPERTY_CHROME, - PathUtil.getInstance().getDriversPath() + settings.getHybridBrowserDriverPath()); } @Override @@ -96,4 +94,17 @@ protected void setBrowserSpecificCapabilities(List addition } } } + + @Override + protected void setupWebDriverManager() { + log.debug("Chrome browser version from EnvironmentsSettings = " + settings.getBrowserVersion()); + + WebDriverManager chromeDriver = WebDriverManager.chromedriver(); + String chromeDriverLocation = PathUtil.getInstance().getRootPath() + "/web-drivers"; + log.debug("chromeDriverLocation = " + chromeDriverLocation); + chromeDriver.cachePath(chromeDriverLocation).setup(); + + log.info("Downloaded ChromeDriver version = " + chromeDriver.getDownloadedDriverVersion()); + log.info("ChromeDriver downloaded location = " + chromeDriver.getDownloadedDriverPath()); + } } diff --git a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java index 72f209ff9..3fb7c685f 100644 --- a/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/EdgeDriver.java @@ -11,6 +11,7 @@ import org.openqa.selenium.edge.EdgeOptions; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; +import io.github.bonigarcia.wdm.WebDriverManager; import java.net.MalformedURLException; import java.util.List; @@ -41,8 +42,6 @@ protected void setTestsigmaLabCapabilities() throws AutomatorException { @Override public void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); - System.setProperty(TSCapabilityType.BROWSER_DRIVER_PROPERTY_EDGE, - PathUtil.getInstance().getDriversPath() + settings.getHybridBrowserDriverPath()); } @Override @@ -51,4 +50,17 @@ protected void setBrowserSpecificCapabilities(List addition proxyOptions.put("proxyType","system"); capabilities.add(new WebDriverCapability(TSCapabilityType.AVOID_PROXY, proxyOptions)); } + + @Override + protected void setupWebDriverManager() { + log.debug("Edge browser version from EnvironmentsSettings = " + settings.getBrowserVersion()); + + WebDriverManager edgeDriver = WebDriverManager.edgedriver(); + String edgeDriverLocation = PathUtil.getInstance().getRootPath() + "/web-drivers"; + log.debug("edgeDriverLocation = " + edgeDriverLocation); + edgeDriver.cachePath(edgeDriverLocation).setup(); + + log.info("Downloaded EdgeDriver version = " + edgeDriver.getDownloadedDriverVersion()); + log.info("EdgeDriver downloaded location = " + edgeDriver.getDownloadedDriverPath()); + } } diff --git a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java index 2ffa99804..364b64917 100644 --- a/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/FirefoxDriver.java @@ -5,6 +5,7 @@ import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.utilities.PathUtil; +import io.github.bonigarcia.wdm.WebDriverManager; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.log4j.Log4j2; @@ -73,8 +74,6 @@ protected void setAdditionalCapabilities(List additionalCap @Override public void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); - System.setProperty(TSCapabilityType.BROWSER_DRIVER_PROPERTY_FIREFOX, - PathUtil.getInstance().getDriversPath() + settings.getHybridBrowserDriverPath()); } @Override @@ -111,4 +110,17 @@ protected void setTimeouts() throws AutomatorException { } } + @Override + protected void setupWebDriverManager() { + log.debug("Firefox browser version from EnvironmentsSettings = " + settings.getBrowserVersion()); + + WebDriverManager firefoxDriver = WebDriverManager.firefoxdriver(); + String firefoxDriverLocation = PathUtil.getInstance().getRootPath() + "/web-drivers"; + log.debug("firefoxDriverLocation = " + firefoxDriverLocation); + firefoxDriver.cachePath(firefoxDriverLocation).setup(); + + log.info("Downloaded FirefoxDriver version = " + firefoxDriver.getDownloadedDriverVersion()); + log.info("FirefoxDriver downloaded location = " + firefoxDriver.getDownloadedDriverPath()); + } + } diff --git a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java index 6ba802c1e..a9c4e9bf2 100644 --- a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java @@ -8,6 +8,8 @@ import com.testsigma.automator.http.HttpClient; import com.testsigma.automator.http.HttpResponse; import com.testsigma.automator.runners.EnvironmentRunner; +import com.testsigma.automator.utilities.PathUtil; +import io.github.bonigarcia.wdm.WebDriverManager; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.log4j.Log4j2; @@ -89,4 +91,17 @@ public void setTimeouts() throws AutomatorException { super.setTimeouts(); } } + + @Override + protected void setupWebDriverManager() { + log.debug("SafariDriver browser version from EnvironmentsSettings = " + settings.getBrowserVersion()); + + WebDriverManager safariDriver = WebDriverManager.safaridriver(); + String safariDriverLocation = PathUtil.getInstance().getRootPath() + "/web-drivers"; + log.debug("safariDriverLocation = " + safariDriverLocation); + safariDriver.cachePath(safariDriverLocation).setup(); + + log.info("Downloaded SafariDriver version = " + safariDriver.getDownloadedDriverVersion()); + log.info("SafariDriver downloaded location = " + safariDriver.getDownloadedDriverPath()); + } } diff --git a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java index 17865c552..5713da6c0 100644 --- a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java @@ -34,8 +34,13 @@ public class WebDriver extends TestsigmaDriver { public WebDriver() { super(); + if(executionLabType == ExecutionLabType.Hybrid) { + setupWebDriverManager(); + } } + protected void setupWebDriverManager() {}; + @Override protected void setCapabilities() throws AutomatorException, MalformedURLException { super.setCapabilities(); @@ -135,4 +140,5 @@ protected String getSafariVersion() { String userAgent = (String) remoteWebDriver.executeScript("return navigator.userAgent;"); return userAgent.substring(userAgent.indexOf("Version") + 8, userAgent.indexOf("Safari") - 1); } + } diff --git a/automator/src/com/testsigma/automator/runners/EnvironmentRunner.java b/automator/src/com/testsigma/automator/runners/EnvironmentRunner.java index 3d700e5b6..228c76e25 100644 --- a/automator/src/com/testsigma/automator/runners/EnvironmentRunner.java +++ b/automator/src/com/testsigma/automator/runners/EnvironmentRunner.java @@ -3,7 +3,6 @@ import com.testsigma.automator.constants.ExecutionStatus; import com.testsigma.automator.constants.AutomatorMessages; -import com.testsigma.automator.drivers.DriversUpdateService; import com.testsigma.automator.entity.*; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException; @@ -103,9 +102,6 @@ protected void beforeExecute() throws AutomatorException { checkForEmptyEnvironment(); new ScreenCaptureUtil().createScreenshotsFolder(); new ErrorUtil().checkError(testDeviceEntity.getErrorCode(), null); - if (testDeviceEntity.getWorkspaceType()==WorkspaceType.WebApplication){ - new DriversUpdateService().syncBrowserDriver(testDeviceEntity); - } } public EnvironmentRunResult run() { From 62dcbdd33827c58e007710db4a2ff67a07e98c27 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 6 Jun 2023 15:52:07 +0530 Subject: [PATCH 32/41] TRD-217 Added logic to extract uiautomator2 and xcuitest driver from the respective zip files. --- .../agent/mobile/MobileAutomationServer.java | 92 +++++++++++++++++-- .../com/testsigma/agent/utils/PathUtil.java | 6 +- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java index 03b473611..82d8cd991 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java @@ -12,19 +12,24 @@ import com.testsigma.agent.utils.NetworkUtil; import com.testsigma.agent.utils.PathUtil; -import io.appium.java_client.service.local.AppiumDriverLocalService; -import io.appium.java_client.service.local.AppiumServiceBuilder; -import io.appium.java_client.service.local.flags.GeneralServerFlag; import lombok.Getter; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.SystemUtils; import org.springframework.stereotype.Component; import javax.annotation.PreDestroy; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.net.InetAddress; import java.net.UnknownHostException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Enumeration; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; @Log4j2 @Component @@ -82,7 +87,7 @@ public void start() { this.logFilePath = new File(PathUtil.getInstance().getLogsPath() + File.separator + "appium.log"); Integer serverPort = NetworkUtil.getFreePort(); this.serverURL = String.format("http://%s:%d", serverIpAddress, serverPort); - + extractMobileAutomationDrivers(); log.info("Starting Mobile Automation Server at - " + serverURL); (new Thread(() -> { @@ -114,6 +119,81 @@ public void start() { } } + private void extractMobileAutomationDrivers(){ + log.info("Trying to check if driver folder is present inside Appium directory"); + try{ + if (!isDriverFolderExists()) { + log.info("Driver folder does not exits.Extracting from the zip files"); + File androidDriverLocalPath = Paths.get(PathUtil.getInstance().getMobileAutomationServerPath(), "appium-uiautomator2-driver.zip").toFile(); + File iOsDriverLocalPath = Paths.get(PathUtil.getInstance().getMobileAutomationServerPath(), "appium-xcuitest-driver.zip").toFile(); + File destinationPath = new File(PathUtil.getInstance().getMobileAutomationDriverDestinationPath()); + ExecutorService executor = Executors.newFixedThreadPool(2); + Future unzipAndroidDriver = executor.submit(() -> { + try { + unzipDriver(androidDriverLocalPath,destinationPath); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + }); + Future unzipIosDriver = executor.submit(() -> { + try { + unzipDriver(iOsDriverLocalPath,destinationPath); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + }); + try { + // Wait for the tasks to complete within the timeout duration + int timeoutSeconds = 120; + unzipAndroidDriver.get(timeoutSeconds, TimeUnit.SECONDS); + unzipIosDriver.get(timeoutSeconds, TimeUnit.SECONDS); + log.info("Unzipped completed successfully"); + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + executor.shutdown(); + } + } + } catch (Exception e){ + log.error(e.getMessage(), e); + } + } + + private boolean isDriverFolderExists() { + String dirPath = appiumHome.getAbsolutePath(); + log.info("Verifying if driver folder exists: " + dirPath); + File driverDirectoryFile = new File(dirPath); + if (driverDirectoryFile.exists()) { + File driverFile = new File(driverDirectoryFile.getAbsolutePath()); + return driverFile.exists() && driverFile.isDirectory(); + } + return false; + } + + private void unzipDriver(File sourcePath,File destinationPath) throws IOException { + File fileZip = new File(String.valueOf(sourcePath)); + File destDir = new File(String.valueOf(destinationPath)); + + try (ZipFile zipFile = new ZipFile(fileZip)) { + Enumeration entries = zipFile.entries(); + + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (!entry.isDirectory()) { + String entryName = entry.getName(); + // to skip creating the "_MACOSX" directory + if (!entryName.startsWith("__MACOSX")) { + File entryFile = new File(destDir, entryName); + Files.createDirectories(entryFile.getParentFile().toPath()); + Files.copy(zipFile.getInputStream(entry), entryFile.toPath()); + } + } + } + } catch (Exception e) { + log.error(e.getMessage(),e); + } + } + @PreDestroy public void stop() { log.info("Stopping Mobile Automation Server..."); diff --git a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java index c9269d63a..38e715031 100644 --- a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java +++ b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java @@ -41,6 +41,9 @@ public class PathUtil { @Getter private String mobileAutomationDriverPath = null; + + @Getter + private String mobileAutomationDriverDestinationPath = null; @Getter private String upgradePath = null; @Getter @@ -82,7 +85,8 @@ public void setPathsFromContext(boolean reset) { driversPath = rootPath + File.separator + "drivers"; jrePath = rootPath + File.separator + "jre"; mobileAutomationServerPath = rootPath + File.separator + "appium"; - mobileAutomationDriverPath = mobileAutomationServerPath + "/drivers"; + mobileAutomationDriverPath = mobileAutomationServerPath + File.separator +"drivers"; + mobileAutomationDriverDestinationPath = mobileAutomationDriverPath + File.separator + "node_modules"; androidPath = rootPath + File.separator + "android"; iosPath = rootPath + File.separator + "ios"; From 47a9d84d2819ffe927e418ea03b3a21bd8693858 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Thu, 8 Jun 2023 11:19:25 +0530 Subject: [PATCH 33/41] bug: name for edge browser is changed in grid4 --- .../com/testsigma/service/PrivateGridService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/testsigma/service/PrivateGridService.java b/server/src/main/java/com/testsigma/service/PrivateGridService.java index bf0580e2a..3e3afe053 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridService.java @@ -66,11 +66,15 @@ private void fetchBrowsersFromNode(String proxy, String gridURL) throws Testsigm JSONObject nodeDetails = (JSONObject) nodeStereotypes.get(i); JSONObject stereotype = (JSONObject) nodeDetails.get("stereotype"); browserDetails = new JSONObject(); - browserDetails.put("browserName", StringUtils.capitalize(stereotype.get("browserName").toString().toLowerCase().replaceAll("\\s", ""))); + if (String.valueOf(stereotype.get("browserName")).contains("edge") || String.valueOf(stereotype.get("browserName")).contains("Edge")) + { + browserDetails.put("browserName", "Edge"); + } else + { + browserDetails.put("browserName", StringUtils.capitalize(stereotype.get("browserName").toString().toLowerCase().replaceAll("\\s", ""))); + } browserDetails.put("maxInstances",Integer.parseInt(nodeDetails.get("slots").toString())); -// if (OSBrowserType.getBrowserEnumValueIfExists(String.valueOf(browserDetails.get("browserName")))==null){ -// continue; -// } + if (String.valueOf(stereotype.get("platformName")).contains("Win") || String.valueOf(stereotype.get("platformName")).contains("WIN")) { browserDetails.put("platform", "Windows"); @@ -103,7 +107,7 @@ private void fetchBrowsersFromNode(String proxy, String gridURL) throws Testsigm if (e instanceof TestsigmaException) throw new TestsigmaException(e.getMessage()); else - throw new TestsigmaException("Unable extract and save the node configurations from your private grid"); + throw new TestsigmaException("Unable to extract and save the node configurations from your private grid"); } } From 9779297acd31644006accf80fbdbe86ee04e9e13 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Fri, 9 Jun 2023 15:19:07 +0530 Subject: [PATCH 34/41] TRD-217 Fixed null pointer exception related to wda process. --- .../main/java/com/testsigma/agent/mobile/ios/WdaService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/ios/WdaService.java b/agent/src/main/java/com/testsigma/agent/mobile/ios/WdaService.java index 57eef456d..b0d71b9c6 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/ios/WdaService.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/ios/WdaService.java @@ -145,7 +145,7 @@ public void startWdaOnDevice(MobileDevice device) throws TestsigmaException { private void checkWDAProcessStatus(MobileDevice device) throws TestsigmaException, AutomatorException, InterruptedException { int retries = 3; - while (device.getWdaProcess() == null && (device.getWdaProcess().isAlive() || device.getWdaProcess().exitValue() == 0) && retries-- > 0) { + while (device.getWdaProcess() == null && retries-- > 0) { log.info("WDA process not started yet, waiting for 5 seconds..."); Thread.sleep(5000); } @@ -161,7 +161,7 @@ private void checkWDAProcessStatus(MobileDevice device) throws TestsigmaExceptio private void checkWDARelayProcessStatus(MobileDevice device) throws TestsigmaException, AutomatorException, InterruptedException { int retries = 3; - while (device.getWdaRelayProcess() == null && !device.getWdaRelayProcess().isAlive() && retries-- > 0) { + while (device.getWdaRelayProcess() == null && retries-- > 0) { log.info("WDA process not started yet, waiting for 5 seconds..."); Thread.sleep(5000); } From 6146b415cee7b978a9212c9bb87cf223303345d0 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 13 Jun 2023 11:24:36 +0530 Subject: [PATCH 35/41] TRD-217 Addressed review comments. --- .../com/testsigma/agent/mobile/MobileAutomationServer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java index 82d8cd991..bd6b64fff 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/MobileAutomationServer.java @@ -16,9 +16,9 @@ import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.SystemUtils; import org.springframework.stereotype.Component; - import javax.annotation.PreDestroy; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.file.Files; @@ -147,7 +147,7 @@ private void extractMobileAutomationDrivers(){ int timeoutSeconds = 120; unzipAndroidDriver.get(timeoutSeconds, TimeUnit.SECONDS); unzipIosDriver.get(timeoutSeconds, TimeUnit.SECONDS); - log.info("Unzipped completed successfully"); + log.info("Unzip completed successfully"); } catch (Exception e) { log.error(e.getMessage(), e); } finally { From 374a7a1ed20bac90a6285ab63a0fbbd6a7ea4c5e Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 13 Jun 2023 11:32:00 +0530 Subject: [PATCH 36/41] TRD-217 correcting indentation --- agent/src/main/java/com/testsigma/agent/utils/PathUtil.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java index 38e715031..8b1bb800b 100644 --- a/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java +++ b/agent/src/main/java/com/testsigma/agent/utils/PathUtil.java @@ -38,10 +38,8 @@ public class PathUtil { private String iosPath = null; @Getter private String mobileAutomationServerPath = null; - @Getter private String mobileAutomationDriverPath = null; - @Getter private String mobileAutomationDriverDestinationPath = null; @Getter From b1b94f640f06d723f5255fca42b76dcb8ea5fbe4 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 13 Jun 2023 11:36:00 +0530 Subject: [PATCH 37/41] chore: remove unused imports --- .../agent/mobile/ios/IosMobileAutomationServer.java | 1 - .../src/com/testsigma/automator/actions/ElementAction.java | 1 - .../actions/mobile/FindElementByIndexAndSendKeysAction.java | 4 +--- .../android/generic/ChangeScreenOrientationAction.java | 1 - .../android/press/MobileNativePressBackSpaceAction.java | 1 - .../ScrollInsideAnElementFromMiddleToBottomAction.java | 5 ----- .../testsigma/service/TestsigmaLabDriverSettingsService.java | 4 +--- 7 files changed, 2 insertions(+), 15 deletions(-) diff --git a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java index f67fb7cea..56f555ab8 100644 --- a/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java +++ b/agent/src/main/java/com/testsigma/agent/mobile/ios/IosMobileAutomationServer.java @@ -15,7 +15,6 @@ import com.testsigma.agent.mobile.MobileAutomationServerService; import com.testsigma.agent.mobile.DeviceContainer; import com.testsigma.agent.mobile.MobileDevice; -import io.appium.java_client.AppiumDriver; import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.remote.MobileCapabilityType; import lombok.RequiredArgsConstructor; diff --git a/automator/src/com/testsigma/automator/actions/ElementAction.java b/automator/src/com/testsigma/automator/actions/ElementAction.java index a677cde51..52bc8581f 100644 --- a/automator/src/com/testsigma/automator/actions/ElementAction.java +++ b/automator/src/com/testsigma/automator/actions/ElementAction.java @@ -26,7 +26,6 @@ import org.openqa.selenium.support.ui.UnexpectedTagNameException; import org.openqa.selenium.support.ui.WebDriverWait; -import java.time.Duration; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java index bec7507f3..cc0517321 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/FindElementByIndexAndSendKeysAction.java @@ -1,6 +1,5 @@ package com.testsigma.automator.actions.mobile; -import com.google.common.collect.ImmutableMap; import com.testsigma.automator.entity.Platform; import com.testsigma.automator.actions.ElementSearchCriteria; import io.appium.java_client.AppiumDriver; @@ -8,7 +7,6 @@ import lombok.Setter; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.DriverCommand; import java.util.ArrayList; import java.util.List; @@ -23,7 +21,7 @@ public class FindElementByIndexAndSendKeysAction extends MobileElementAction { Integer index; @Getter @Setter - String webViewName; + String webViewName; @Getter @Setter String keys; diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java index 242079671..19807f1d5 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/generic/ChangeScreenOrientationAction.java @@ -1,7 +1,6 @@ package com.testsigma.automator.actions.mobile.android.generic; import com.google.common.collect.ImmutableMap; -import com.testsigma.automator.actions.mobile.generic.GetScreenOrientationAction; import org.openqa.selenium.ScreenOrientation; import org.openqa.selenium.remote.DriverCommand; diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java index 0264ca2e3..fb0d21140 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/press/MobileNativePressBackSpaceAction.java @@ -10,7 +10,6 @@ package com.testsigma.automator.actions.mobile.android.press; import com.testsigma.automator.actions.mobile.MobileElementAction; -import com.testsigma.automator.actions.mobile.ios.presskey.PressBackSpaceKeyAction; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.nativekey.AndroidKey; import io.appium.java_client.android.nativekey.KeyEvent; diff --git a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java index 1ae898066..9170bcef9 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/android/scroll/ScrollInsideAnElementFromMiddleToBottomAction.java @@ -1,15 +1,10 @@ package com.testsigma.automator.actions.mobile.android.scroll; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.TouchAction; -import io.appium.java_client.touch.WaitOptions; -import io.appium.java_client.touch.offset.PointOption; -import org.openqa.selenium.Dimension; import org.openqa.selenium.Rectangle; import org.openqa.selenium.interactions.PointerInput; import org.openqa.selenium.interactions.Sequence; -import java.time.Duration; import java.util.Arrays; import static java.time.Duration.ofMillis; diff --git a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java index 5f76df62d..bd1cd6d19 100644 --- a/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java +++ b/server/src/main/java/com/testsigma/service/TestsigmaLabDriverSettingsService.java @@ -25,9 +25,7 @@ public class TestsigmaLabDriverSettingsService extends DriverSettingsService { public static final String PLATFORM_WEB_URL_WITH_PORT = "%s://%s:%s@%s:%s/wd/hub"; public static final String PLATFORM_MOBILE_URL = "%s://%s:%s@%s/mobile/wd/hub"; public static final String PLATFORM_MOBILE_URL_WITH_PORT = "%s://%s:%s@%s:%s/mobile/wd/hub"; - - - + @Autowired PlatformsService platformsService; @Autowired From d8ba1e4796ba0e3abd8dac51722f30ea07a2b5db Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 13 Jun 2023 11:51:43 +0530 Subject: [PATCH 38/41] chore: remove unused imports --- .../testsigma/automator/actions/CustomExpectedConditions.java | 4 ---- .../actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java | 2 -- .../automator/actions/mobile/tap/MobileNativeTapSnippet.java | 3 --- .../actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java | 2 -- .../mobile/tap/TapOnElementUsingCoordinatesAction.java | 2 -- 5 files changed, 13 deletions(-) diff --git a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java index 7b85f0eba..34bb5932c 100644 --- a/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java +++ b/automator/src/com/testsigma/automator/actions/CustomExpectedConditions.java @@ -4,16 +4,12 @@ import org.openqa.selenium.*; import org.openqa.selenium.remote.UnreachableBrowserException; import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.FluentWait; -import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; import java.util.List; import java.util.Set; -import static java.util.concurrent.TimeUnit.SECONDS; - @Log4j2 public class CustomExpectedConditions { diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java index 0ffbcb98a..1ffe53873 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapCoordinatesSnippet.java @@ -11,8 +11,6 @@ import com.testsigma.automator.actions.constants.ErrorCodes; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.TouchAction; -import io.appium.java_client.touch.offset.PointOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.interactions.Pause; diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java index 4c33aeb25..576072590 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/MobileNativeTapSnippet.java @@ -10,9 +10,6 @@ package com.testsigma.automator.actions.mobile.tap; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.TouchAction; -import io.appium.java_client.touch.TapOptions; -import io.appium.java_client.touch.offset.ElementOption; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.interactions.Pause; import org.openqa.selenium.interactions.PointerInput; diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java index dc755922d..0e7cfbdb5 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnCoordinatesRelativeToScreen.java @@ -2,8 +2,6 @@ import com.testsigma.automator.formatters.NumberFormatter; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.TouchAction; -import io.appium.java_client.touch.offset.PointOption; import org.openqa.selenium.Dimension; import org.openqa.selenium.interactions.Pause; import org.openqa.selenium.interactions.PointerInput; diff --git a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java index 6f15c6f8e..311e193df 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/tap/TapOnElementUsingCoordinatesAction.java @@ -1,8 +1,6 @@ package com.testsigma.automator.actions.mobile.tap; import com.testsigma.automator.actions.mobile.MobileElementAction; -import io.appium.java_client.TouchAction; -import io.appium.java_client.touch.offset.PointOption; import org.openqa.selenium.Rectangle; import org.openqa.selenium.interactions.Pause; import org.openqa.selenium.interactions.PointerInput; From 07329738b0e8e3070bcf3b97b5708700e5e8c9b3 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 13 Jun 2023 12:01:58 +0530 Subject: [PATCH 39/41] chore: code style fixes --- .../actions/mobile/ios/generic/HideKeyboardAction.java | 3 --- .../actions/mobile/ios/settings/DisableWIFIAction.java | 2 -- .../actions/mobile/ios/settings/EnableWIFIAction.java | 2 -- .../src/com/testsigma/automator/drivers/web/SafariDriver.java | 2 -- .../com/testsigma/automator/runners/TestcaseStepRunner.java | 1 - .../main/java/com/testsigma/service/PrivateGridService.java | 1 - 6 files changed, 11 deletions(-) diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java index 46b692969..bfca26b9c 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/generic/HideKeyboardAction.java @@ -2,7 +2,6 @@ import com.testsigma.automator.actions.mobile.MobileElementAction; import io.appium.java_client.AppiumBy; -import io.appium.java_client.MobileBy; import io.appium.java_client.ios.IOSDriver; import lombok.extern.log4j.Log4j2; import org.openqa.selenium.By; @@ -131,6 +130,4 @@ protected void resetImplicitTimeout() { } } - - } diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java index 9bf63ec01..d79a090b0 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/DisableWIFIAction.java @@ -6,8 +6,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import java.util.HashMap; - @Log4j2 public class DisableWIFIAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully disabled WIFI."; diff --git a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java index 42c1fc7ed..28088dbd2 100644 --- a/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java +++ b/automator/src/com/testsigma/automator/actions/mobile/ios/settings/EnableWIFIAction.java @@ -6,8 +6,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import java.util.HashMap; - @Log4j2 public class EnableWIFIAction extends MobileElementAction { private static final String SUCCESS_MESSAGE = "Successfully enabled WIFI."; diff --git a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java index a9c4e9bf2..263e3f4dd 100644 --- a/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/SafariDriver.java @@ -1,8 +1,6 @@ package com.testsigma.automator.drivers.web; import com.fasterxml.jackson.core.type.TypeReference; -import com.testsigma.automator.constants.TSCapabilityType; -import com.testsigma.automator.drivers.WebDriverCapability; import com.testsigma.automator.entity.ExecutionLabType; import com.testsigma.automator.exceptions.AutomatorException; import com.testsigma.automator.http.HttpClient; diff --git a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java index 7150baa77..58b8fd5fa 100644 --- a/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java +++ b/automator/src/com/testsigma/automator/runners/TestcaseStepRunner.java @@ -37,7 +37,6 @@ import java.sql.Timestamp; import java.util.*; - @Log4j2 public abstract class TestcaseStepRunner { private static final String[] SKIP_SCREENSHOT_KEYWORDS = {"Close App", "Close all windows"}; diff --git a/server/src/main/java/com/testsigma/service/PrivateGridService.java b/server/src/main/java/com/testsigma/service/PrivateGridService.java index 3e3afe053..8704f66ef 100644 --- a/server/src/main/java/com/testsigma/service/PrivateGridService.java +++ b/server/src/main/java/com/testsigma/service/PrivateGridService.java @@ -92,7 +92,6 @@ private void fetchBrowsersFromNode(String proxy, String gridURL) throws Testsigm mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); PrivateGridBrowserRequest[] browsersList = new ObjectMapperService().parseJson(validPlatforms.toString(), PrivateGridBrowserRequest[].class); -// PrivateGridBrowserRequest[] browsersList = mapper.convertValue(validPlatforms, PrivateGridBrowserRequest[].class); PrivateGridNodeRequest request = new PrivateGridNodeRequest(); request.setNodeName(proxy); request.setGridURL(gridURL); From 634f468149e6469ba3cc3388dbfd9d457d4ab929 Mon Sep 17 00:00:00 2001 From: Vikram VR Date: Tue, 13 Jun 2023 12:07:16 +0530 Subject: [PATCH 40/41] TRD-217 Changed testsigma platform url to default. --- server/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index d129d21fc..f80a5c34f 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -5,7 +5,7 @@ server.local.url=${TESTSIGMA_SERVER_LOCAL_URL:http://localhost:${server.port}} local.agent.url=${LOCAL_AGENT_URL:http://localhost:9393/agent} local.agent.download.tag=latest docker.env=${IS_DOCKER_ENV:false} -testsigma.platform.url=${TESTSIGMA_PLATFORM_URL:https://staging-os-services.testsigma.com} +testsigma.platform.url=${TESTSIGMA_PLATFORM_URL:https://os-services.testsigma.com} ts.root.dir=${TS_DATA_DIR:/opt/app/ts_data} unzip.dir=${UNZIP_HOME_DIR:/usr/bin/} ts.disable.telemetry=${DISABLE_TELEMETRY: false} From 50889d90f01d16baccc225101808468bb4b325d2 Mon Sep 17 00:00:00 2001 From: gayathri019 Date: Tue, 13 Jun 2023 14:28:40 +0530 Subject: [PATCH 41/41] bug: name key in desiredcap for local run --- .../src/com/testsigma/automator/drivers/web/WebDriver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java index 5713da6c0..c11c77bc3 100644 --- a/automator/src/com/testsigma/automator/drivers/web/WebDriver.java +++ b/automator/src/com/testsigma/automator/drivers/web/WebDriver.java @@ -18,8 +18,10 @@ import java.net.MalformedURLException; import java.time.Instant; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; @EqualsAndHashCode(callSuper = true) @Data @@ -68,7 +70,9 @@ protected void setTestsigmaLabCapabilities() throws AutomatorException { @Override protected void setHybridCapabilities() throws AutomatorException, MalformedURLException { super.setHybridCapabilities(); - capabilities.add(new WebDriverCapability(TSCapabilityType.NAME, settings.getExecutionName())); + Map testsigmaOptions = new HashMap<>(); + testsigmaOptions.put(TSCapabilityType.NAME, settings.getExecutionName()); + capabilities.add(new WebDriverCapability(TSCapabilityType.TESTSIGMA_LAB_OPTIONS, testsigmaOptions)); } protected void setBrowserSpecificCapabilities(List additionalCapabilitiesList)