How to use isMobile method of com.testsigma.model.Platform class

Best Testsigma code snippet using com.testsigma.model.Platform.isMobile

Source:AgentExecutionService.java Github

copy

Full Screen

...508 }509 private TestDeviceSettings getExecutionTestDeviceSettings(TestDevice testDevice) throws TestsigmaException {510 TestDeviceSettings settings = new TestDeviceSettings();511 TestPlanLabType exeLabType = testDevice.getTestPlanLabType();512 if (!(testDevice.getTestPlanLabType().isHybrid() && testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isMobile()) && testDevice.getPlatformDeviceId() != null) {513 settings.setDeviceName(platformsService.getPlatformDevice(testDevice.getPlatformDeviceId(), exeLabType).getName());514 }515 if (testDevice.getPlatformBrowserVersionId() != null) {516 PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), exeLabType);517 settings.setBrowserVersion(platformBrowserVersion.getVersion());518 settings.setBrowser(platformBrowserVersion.getName().name());519 }520 if (testDevice.getPlatformScreenResolutionId() != null) {521 settings.setResolution(platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), exeLabType).getResolution());522 }523 if (testDevice.getPlatformOsVersionId() != null) {524 PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), exeLabType);525 settings.setPlatform(platformOsVersion.getPlatform());526 settings.setOsVersion(platformOsVersion.getPlatformVersion());527 }528 if (exeLabType == TestPlanLabType.Hybrid || exeLabType == TestPlanLabType.PrivateGrid) {529 settings.setBrowser(testDevice.getBrowser());530 }531 settings.setAppActivity(testDevice.getAppActivity());532 settings.setAppPackage(testDevice.getAppPackage());533 settings.setAppPathType(testDevice.getAppPathType());534 settings.setAppUrl(testDevice.getAppUrl());535 settings.setAppUploadId(testDevice.getAppUploadId());536 settings.setTitle(testDevice.getTitle());537 settings.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());538 return settings;539 }540 private Boolean isScheduledExecution() {541 return this.triggeredType.equals(ExecutionTriggeredType.SCHEDULED);542 }543 // ############################################ RESULT ENTRIES PROCESSING ###########################################544 private void processResultEntries() throws Exception {545 List<TestDeviceResult> testDeviceResults = testDeviceResultService.findAllByTestPlanResultId(546 this.testPlanResult.getId());547 for(TestDeviceResult testDeviceResult : testDeviceResults) {548 if (canPushToLabAgent(testDeviceResult)) {549 processResultEntriesForLabAgent(testDeviceResult);550 } else if (canPushToHybridAgent(testDeviceResult)) {551 processResultEntriesForHybridAgent(testDeviceResult);552 }553 }554 }555 private Boolean canPushToLabAgent(TestDeviceResult testDeviceResult) throws IntegrationNotFoundException {556 return !testDeviceResult.getTestPlanLabType().equals(TestPlanLabType.Hybrid) && this.integrationsService.findByApplication(Integration.TestsigmaLab) != null;557 }558 private Boolean canPushToHybridAgent(TestDeviceResult testDeviceResult) {559 return testDeviceResult.getTestPlanLabType().equals(TestPlanLabType.Hybrid);560 }561 private void processResultEntriesForLabAgent(TestDeviceResult testDeviceResult) throws Exception {562 processResultEntries(testDeviceResult, StatusConstant.STATUS_CREATED);563 }564 private void processResultEntriesForHybridAgent(TestDeviceResult testDeviceResult) throws Exception {565 processResultEntries(testDeviceResult, StatusConstant.STATUS_CREATED);566 }567 public void processResultEntries(TestDeviceResult testDeviceResult, StatusConstant inStatus)568 throws Exception {569 if (testDeviceResult.getTestDevice().getAgent() == null && testDeviceResult.getTestPlanLabType().isHybrid()) {570 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.AGENT_HAS_BEEN_REMOVED, StatusConstant.STATUS_CREATED);571 } else if (testDeviceResult.getTestPlanLabType().isHybrid() && !agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId())) {572 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.AGENT_INACTIVE, StatusConstant.STATUS_CREATED);573 } else if(testDeviceResult.getTestPlanLabType().isHybrid() && testDeviceResult.getTestDevice().getDeviceId()!=null && agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId()) && !agentDeviceService.isDeviceOnline(testDeviceResult.getTestDevice().getDeviceId())){574 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, agentDeviceService.find(testDeviceResult.getTestDevice().getDeviceId()).getName()+ " "+AutomatorMessages.DEVICE_NOT_ONLINE, StatusConstant.STATUS_CREATED);575 } else {576 processEnvironmentResultOnSuccessfulChecks(testDeviceResult, inStatus);577 }578 testDeviceResultService.updateExecutionConsolidatedResults(this.testPlanResult.getId(),579 Boolean.TRUE);580 }581 public void processEnvironmentResultOnSuccessfulChecks(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {582 if (!isWaitingOnEnvironmentPrerequisite(testDeviceResult)) {583 if (testDeviceResult.getPrerequisiteTestDeviceResultId() == null || isEnvironmentPrerequisiteResultSuccessful(testDeviceResult)) {584 processEnvironmentResult(testDeviceResult, inStatus);585 } else {586 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.MSG_EXECUTION_NOT_EXECUTED, StatusConstant.STATUS_QUEUED);587 }588 } else {589 testDeviceResultService.markEnvironmentResultAsQueued(testDeviceResult, inStatus, true);590 }591 }592 private void processEnvironmentResult(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {593 testDeviceResultService.markEnvironmentResultAsInPreFlight(testDeviceResult, inStatus);594 if (!testDeviceResult.getTestPlanLabType().isHybrid()) {595 EnvironmentEntityDTO environmentEntityDTO = loadEnvironment(testDeviceResult,596 StatusConstant.STATUS_PRE_FLIGHT);597 try {598 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);599 } catch (Exception e) {600 log.error(e.getMessage(), e);601 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, e.getMessage(),602 StatusConstant.STATUS_PRE_FLIGHT);603 }604 }605 }606 public void processEnvironmentResultInParallel(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {607 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(608 testDeviceResult, inStatus);609 testDeviceResult.setSuiteResults(testSuiteResults);610 for (TestSuiteResult testSuiteResult : testSuiteResults) {611 if(!isWaitingOnEnvironmentPrerequisite(testDeviceResult)) {612 testSuiteResultService.markTestSuiteResultAsInFlight(testSuiteResult, inStatus);613 if (!testDeviceResult.getTestPlanLabType().isHybrid()) {614 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);615 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, StatusConstant.STATUS_PRE_FLIGHT));616 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();617 testSuiteEntityDTOS.add(testSuiteEntity);618 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);619 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);620 try {621 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);622 } catch (Exception e) {623 log.error(e.getMessage(), e);624 testSuiteResultService.markTestSuiteResultAsFailed(testSuiteResult, e.getMessage(),625 StatusConstant.STATUS_PRE_FLIGHT);626 }627 }628 }629 }630 testDeviceResultService.updateEnvironmentConsolidatedResults(testDeviceResult);631 }632 public EnvironmentEntityDTO loadEnvironment(TestDeviceResult testDeviceResult, StatusConstant inStatus)633 throws Exception {634 List<TestSuiteEntityDTO> testSuiteEntityDTOS = loadTestSuites(testDeviceResult, inStatus);635 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);636 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);637 return environmentEntityDTO;638 }639 public EnvironmentEntityDTO loadEnvironmentDetails(TestDeviceResult testDeviceResult) throws Exception {640 TestPlanSettingEntityDTO testPlanSettingEntityDTO = this.testPlanMapper.mapSettings(this.testPlan);641 EnvironmentEntityDTO environmentEntityDTO = this.testDeviceResultMapper.map(testDeviceResult);642 TestDevice testDevice = testDeviceResult.getTestDevice();643 if (testDevice.getDeviceId() != null) {644 AgentDevice agentDevice = agentDeviceService.find(testDevice.getDeviceId());645 environmentEntityDTO.setAgentDeviceUuid(agentDevice.getUniqueId());646 }647 environmentEntityDTO.setStorageType(storageServiceFactory.getStorageService().getStorageType());648 testDevice.setWorkspaceVersion(workspaceVersionService.find(testDevice.getWorkspaceVersionId()));649 environmentEntityDTO.setWorkspaceType(testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType());650 environmentEntityDTO.setExecutionLabType(testDevice.getTestPlanLabType());651 environmentEntityDTO.setTestPlanSettings(testPlanSettingEntityDTO);652 environmentEntityDTO.setMatchBrowserVersion(testDevice.getMatchBrowserVersion());653 environmentEntityDTO.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());654 TestDeviceSettings settings = getExecutionTestDeviceSettings(testDevice);655 settings.setExecutionName(testPlan.getName());656 settings.setEnvironmentParamId(this.testPlan.getEnvironmentId());657 settings.setEnvRunId(testDeviceResult.getId());658 setTestLabDetails(testDevice, settings,environmentEntityDTO);659 environmentEntityDTO.setEnvSettings(this.testPlanMapper.mapToDTO(settings));660 Agent agent = null;661 if (testDevice.getAgentId() != null)662 agent = this.agentService.find(testDevice.getAgentId());663 setAgentJWTApiKey(environmentEntityDTO, agent);664 setAvailableFeatures(environmentEntityDTO);665 return environmentEntityDTO;666 }667 private List<TestSuiteEntityDTO> loadTestSuites(TestDeviceResult testDeviceResult, StatusConstant inStatus) {668 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();669 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(testDeviceResult,670 inStatus);671 for (TestSuiteResult testSuiteResult : testSuiteResults) {672 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);673 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, inStatus));674 testSuiteEntityDTOS.add(testSuiteEntity);675 }676 return testSuiteEntityDTOS;677 }678 private List<TestCaseEntityDTO> loadTestCases(TestSuiteResult testSuiteResult, StatusConstant inStatus) {679 List<TestCaseResult> testCaseResults = this.testCaseResultService.findActiveSuiteTestCaseResults(680 testSuiteResult.getId(), inStatus);681 List<TestCaseEntityDTO> testCases = new ArrayList<>();682 for (TestCaseResult testCaseResult : testCaseResults) {683 TestCaseEntityDTO testCaseEntity = this.testCaseResultMapper.map(testCaseResult);684 testCaseEntity.setDataDrivenTestCases(loadDataDrivenTestCases(testCaseResult, inStatus));685 testCases.add(testCaseEntity);686 }687 return testCases;688 }689 private List<TestCaseEntityDTO> loadDataDrivenTestCases(TestCaseResult testCaseResult, StatusConstant inStatus) {690 List<TestCaseResult> dataDrivenTestCaseResults =691 this.testCaseResultService.findAllByParentIdAndStatus(testCaseResult.getId(), inStatus);692 return this.testCaseResultMapper.map(dataDrivenTestCaseResults);693 }694 private void setAgentJWTApiKey(EnvironmentEntityDTO environmentEntityDTO, com.testsigma.model.Agent id) throws ResourceNotFoundException {695 TestDeviceSettingsDTO envSettings = environmentEntityDTO.getEnvSettings();696 if (id != null) {697 Agent agent = this.agentService.find(id.getId());698 envSettings.setJwtApiKey(agent.generateJwtApiKey(jwtTokenService.getServerUuid()));699 }700 environmentEntityDTO.setEnvSettings(envSettings);701 }702 private void setAvailableFeatures(EnvironmentEntityDTO dto) throws ResourceNotFoundException, SQLException {703 dto.getTestPlanSettings().setHasSuggestionFeature(true);704 }705 private void pushEnvironmentToLab(TestDeviceResult testDeviceResult, EnvironmentEntityDTO environmentEntityDTO) throws Exception {706 ObjectMapper objectMapper = new ObjectMapper();707 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);708 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);709 TestDeviceEntity testDeviceEntity = objectMapper.readValue(objectMapper.writeValueAsString(environmentEntityDTO),710 TestDeviceEntity.class);711 try {712 testDeviceResultService.markEnvironmentResultAsInProgress(testDeviceResult, StatusConstant.STATUS_PRE_FLIGHT,713 Boolean.TRUE);714 new TestPlanRunTask(testDeviceEntity).start();715 log.info("Successfully pushed Execution Environment[" + testDeviceEntity.getEnvironmentResultId()716 + "] to Testsigma Lab");717 } catch (Exception e) {718 log.error(e.getMessage(), e);719 String message = "Error while pushing environment to agent - " + e.getMessage();720 throw new TestsigmaException(message, message);721 }722 }723 private void saveRunTimeData() {724 JSONObject runtimeJSONObj = this.getRunTimeData();725 if (runtimeJSONObj != null && runtimeJSONObj.has("runtime_data")) {726 RunTimeData runTimeData = new RunTimeData();727 runTimeData.setTestPlanRunId(this.getTestPlanResult().getId());728 if (runtimeJSONObj.has("runtime_data")) {729 runTimeData.setData(runtimeJSONObj.getJSONObject("runtime_data"));730 }731 this.runTimeDataService.create(runTimeData);732 }733 }734 public void checkTestCaseIsInReadyState(TestCase testCase) throws TestsigmaException {735 if (!testCase.getStatus().equals(TestCaseStatus.READY) && testPlan.getEntityType()=="TEST_PLAN") {736 String message = testCase.getIsStepGroup() ? com.testsigma.constants.MessageConstants.getMessage(MessageConstants.STEP_GROUP_NOT_READY, testCase.getName()) :737 MessageConstants.TESTCASE_NOT_READY;738 throw new TestsigmaException(message, message);739 }740 }741 private void fetchEnvironmentResultsReRunList() {742 testDeviceResultsReRunList = new ArrayList<>();743 if (getReRunType() == ReRunType.ALL_TESTS) {744 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultId(this.getParentTestPlanResultId());745 } else if (ReRunType.runFailedTestCases(getReRunType())) {746 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultIdAndResultIsNot747 (this.getParentTestPlanResultId(), ResultConstant.SUCCESS);748 }749 }750 private void fetchTestSuitesResultsReRunList(Long parentEnvironmentResultId) {751 testSuiteResultsReRunList = new ArrayList<>();752 try {753 TestDeviceResult parentTestDeviceResult = testDeviceResultService.find(parentEnvironmentResultId);754 List<TestSuiteResult> failedTestSuites;755 if (parentTestDeviceResult != null) {756 if (getReRunType() == ReRunType.ALL_TESTS) {757 testSuiteResultsReRunList = testSuiteResultService.findAllByEnvironmentResultId(parentTestDeviceResult.getId());758 } else if (ReRunType.runFailedTestCases(getReRunType())) {759 failedTestSuites = testSuiteResultService.findAllByEnvironmentResultIdAndResultIsNot760 (parentTestDeviceResult.getId(), ResultConstant.SUCCESS);761 if (failedTestSuites.size() > 0) {762 for (TestSuiteResult testSuiteResult : failedTestSuites) {763 List<Long> testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(testSuiteResult, new ArrayList<>(), 0);764 if (testSuitePreRequisiteIds.size() > 0) {765 List<TestSuiteResult> preRequisiteResults = testSuiteResultService.findBySuiteResultIds(testSuitePreRequisiteIds);766 testSuiteResultsReRunList.addAll(preRequisiteResults);767 }768 testSuiteResultsReRunList.add(testSuiteResult);769 }770 }771 }772 }773 } catch (Exception e) {774 log.error(e.getMessage(), e);775 }776 }777 private List<Long> findTestSuitePreRequisiteIds(TestSuiteResult testSuiteResult, List<Long> testSuitePreRequisiteIds,778 int depth) {779 if (depth < PRE_REQUISITE_DEPTH) {780 TestSuiteResult preReqTestSuiteResult;781 try {782 TestSuite testSuite = testSuiteResult.getTestSuite();783 if (testSuite.getPreRequisite() != null) {784 preReqTestSuiteResult = testSuiteResultService.findByEnvironmentResultIdAndSuiteId(785 testSuiteResult.getEnvironmentResultId(), testSuite.getPreRequisite());786 if (preReqTestSuiteResult != null) {787 testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(preReqTestSuiteResult, testSuitePreRequisiteIds,788 depth + 1);789 testSuitePreRequisiteIds.add(preReqTestSuiteResult.getId());790 }791 }792 } catch (Exception e) {793 log.error(e.getMessage(), e);794 }795 }796 return testSuitePreRequisiteIds;797 }798 private void fetchTestCaseResultsReRunList(Long parentTestSuiteResultId) {799 testCaseResultsReRunList = new ArrayList<>();800 try {801 TestSuiteResult parentTestSuiteResult = testSuiteResultService.find(parentTestSuiteResultId);802 List<TestCaseResult> failedTestCases = new ArrayList<>();803 if (parentTestSuiteResult != null) {804 if (getReRunType() == ReRunType.ALL_TESTS || isTestSuiteAPrerequisite(parentTestSuiteResult)) {805 testCaseResultsReRunList = testCaseResultService.findAllBySuiteResultId(parentTestSuiteResult.getId());806 } else if (ReRunType.runFailedTestCases(getReRunType())) {807 if(getReRunType() == ReRunType.ALL_ITERATIONS) {808 log.info("Fetching all iterations in failed data driven test case results for suite result id - " + parentTestSuiteResult.getId());809 List<TestCaseResult> failedTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndIsDataDrivenTrueAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);810 for (TestCaseResult testCaseResult : failedTestCaseResults) {811 failedTestCases.addAll(testCaseResultService.findAllBySuiteResultIdAndTestCaseId(parentTestSuiteResult.getId(), testCaseResult.getTestCaseId()));812 }813 }814 else if(getReRunType() == ReRunType.ONLY_FAILED_ITERATIONS_IN_FAILED_TESTS) {815 log.info("Fetching all failed data driven test case results re run list for suite result id - " + parentTestSuiteResult.getId());816 List<TestCaseResult> failedTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndIsDataDrivenTrueAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);817 for (TestCaseResult testCaseResult : failedTestCaseResults) {818 failedTestCases.addAll(testCaseResultService.findAllBySuiteResultIdAndTestCaseIdAndResultIsNot(parentTestSuiteResult.getId(), testCaseResult.getTestCaseId(), ResultConstant.SUCCESS));819 }820 }821 else {822 log.info("Fetching all failed test case results re run list for suite result id - " + parentTestSuiteResult.getId());823 failedTestCases = testCaseResultService.findAllBySuiteResultIdAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);824 }825 if (failedTestCases.size() > 0) {826 for (TestCaseResult testCaseResult : failedTestCases) {827 List<Long> testCasePreRequisiteIds = findTestCasePreRequisiteIds(testCaseResult, new ArrayList<>(), 0);828 //If a prerequisite is failed, it will be already available in failedTestCases. So we need to add only prerequisites with SUCCESS status.829 List<TestCaseResult> preRequisiteResults = fetchPreRequisiteTestCaseResultsWithSuccessStatus(testCasePreRequisiteIds);830 testCaseResultsReRunList.addAll(preRequisiteResults);831 testCaseResultsReRunList.add(testCaseResult);832 }833 }834 }835 }836 } catch (Exception e) {837 log.error(e.getMessage(), e);838 }839 }840 private List<TestCaseResult> fetchPreRequisiteTestCaseResultsWithSuccessStatus(List<Long> testCasePreRequisiteIds) {841 List<TestCaseResult> preRequisitesWithSuccessStatus = new ArrayList<>();842 List<TestCaseResult> preRequisiteResults = testCaseResultService.findByTestCaseResultIds(testCasePreRequisiteIds);843 for (TestCaseResult testCaseResult : preRequisiteResults) {844 if (testCaseResult.getResult() == ResultConstant.SUCCESS) {845 preRequisitesWithSuccessStatus.add(testCaseResult);846 }847 }848 return preRequisitesWithSuccessStatus;849 }850 private boolean isTestSuiteAPrerequisite(TestSuiteResult testSuiteResult) {851 List<TestSuite> testSuites = testSuiteService.findByPrerequisiteId(testSuiteResult.getSuiteId());852 for (TestSuite testSuite : testSuites) {853 TestSuiteResult baseTestSuiteResult = testSuiteResultService.findByEnvironmentResultIdAndSuiteId(testSuiteResult.getEnvironmentResultId(), testSuite.getId());854 if (baseTestSuiteResult != null) {855 return true;856 }857 }858 return false;859 }860 private List<Long> findTestCasePreRequisiteIds(TestCaseResult testCaseResult, List<Long> testCasePreRequisiteIds,861 int depth) {862 if (depth < PRE_REQUISITE_DEPTH) {863 List<TestCaseResult> preReqTestCaseResults;864 try {865 TestCase testCase = testCaseResult.getTestCase();866 if (testCase.getPreRequisite() != null) {867 //In case of data-driven tests, we have multiple rows in TestCaseResult table for each dataset(each row in testdata profile)868 preReqTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndTestCaseId(869 testCaseResult.getSuiteResultId(), testCase.getPreRequisite());870 if (preReqTestCaseResults != null) {871 for (TestCaseResult preReqTestCaseResult : preReqTestCaseResults) {872 testCasePreRequisiteIds = findTestCasePreRequisiteIds(preReqTestCaseResult, testCasePreRequisiteIds,873 depth + 1);874 testCasePreRequisiteIds.add(preReqTestCaseResult.getId());875 }876 }877 }878 } catch (Exception e) {879 log.error(e.getMessage(), e);880 }881 }882 return testCasePreRequisiteIds;883 }884 // ################################################ AFTER START ###################################################885 private void afterStart() throws Exception {886 setInitialCounts();887 }888 private void setInitialCounts() {889 List<TestDeviceResult> executionEnvironmentsResults890 = testDeviceResultService.findAllByTestPlanResultId(this.getTestPlanResult().getId());891 for (TestDeviceResult executionTestDeviceResult : executionEnvironmentsResults) {892 List<TestCaseResult> testCaseResults = testCaseResultService.findAllByEnvironmentResultId(executionTestDeviceResult.getId());893 for (TestCaseResult testCaseResult : testCaseResults) {894 testCaseResultService.updateResultCounts(testCaseResult);895 }896 List<TestSuiteResult> testSuitesResults = testSuiteResultService.findAllByEnvironmentResultId(executionTestDeviceResult.getId());897 for (TestSuiteResult testSuiteResult : testSuitesResults) {898 testSuiteResultService.updateResultCounts(testSuiteResult.getId());899 }900 testDeviceResultService.updateResultCounts(executionTestDeviceResult.getId());901 }902 }903 // ################################################ STOP ###################################################904 public void stop() throws Exception {905 beforeStop();906 stopQueuedEnvironments(AutomatorMessages.MSG_USER_ABORTED_EXECUTION, Boolean.TRUE);907 afterStop();908 }909 private void beforeStop() throws TestsigmaException {910 TestPlanResult testPlanResult = this.testPlanResultService.findByTestPlanIdAndStatusIsNot(this.testPlan.getId(),911 StatusConstant.STATUS_COMPLETED);912 if (testPlanResult == null) {913 throw new TestsigmaException("No Queued executions for test plan - " + this.getTestPlan().getName());914 }915 this.setTestPlanResult(testPlanResult);916 }917 private void stopQueuedEnvironments(String errorMessage, Boolean sendPendingExecutions) {918 List<TestDeviceResult> testDeviceResults = this.testDeviceResultService919 .findAllByTestPlanResultIdAndStatusIsNot(this.testPlanResult.getId(), StatusConstant.STATUS_COMPLETED);920 for (TestDeviceResult testDeviceResult : testDeviceResults) {921 testDeviceResultService.markEnvironmentResultAsStopped(testDeviceResult, errorMessage);922 testDeviceResultService.updateResultCounts(testDeviceResult.getId());923 }924 Timestamp currentTime = new Timestamp(java.lang.System.currentTimeMillis());925 TestPlanResult testPlanResult = this.testPlanResult;926 testPlanResult.setResult(ResultConstant.STOPPED);927 testPlanResult.setStatus(StatusConstant.STATUS_COMPLETED);928 testPlanResult.setMessage(errorMessage);929 testPlanResult.setEndTime(currentTime);930 testPlanResult.setDuration(testPlanResult.getEndTime().getTime() - testPlanResult.getStartTime().getTime());931 this.testPlanResultService.update(testPlanResult);932 try {933 if (sendPendingExecutions) {934 testDeviceResultService.sendPendingTestPlans();935 }936 } catch (Exception e) {937 log.error(e.getMessage(), e);938 }939 }940 private void afterStop() {941 }942 protected void setTestLabDetails(TestDevice testDevice, TestDeviceSettings settings,EnvironmentEntityDTO environmentEntityDTO)943 throws Exception {944 if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isRest())945 return;946 TestPlanLabType exeLabType = testDevice.getTestPlanLabType();947 setPlatformDetails(testDevice, settings, exeLabType, testDevice.getAgent(), environmentEntityDTO);948 }949 public void loadTestCase(String testDataSetName, TestCaseEntityDTO testCaseEntityDTO, AbstractTestPlan testPlan, TestDevice testDevice,950 Workspace workspace) throws Exception {951 String profileName = null;952 String environmentProfileName = null;953 Map<String, String> environmentParameters = null;954 List<com.testsigma.model.TestDataSet> databank = new ArrayList<>();955 com.testsigma.model.TestDataSet dataSet = null;956 if (testPlan.getEnvironmentId() != null) {957 Environment environment = testPlan.getEnvironment();958 environmentParameters = environment.getData();959 environmentProfileName = environment.getName();960 }961 List<TestStep> testSteps = testStepService.findAllByTestCaseIdAndEnabled(testCaseEntityDTO.getId());962 List<TestStepDTO> testStepDTOS = testStepMapper.mapDTOs(testSteps);963 Long testDataId = testCaseEntityDTO.getTestDataId();964 if (testDataId != null) {965 TestData testData = testDataProfileService.find(testCaseEntityDTO.getTestDataId());966 testCaseEntityDTO.setTestDataProfileName(testData.getTestDataName());967 databank = testData.getData();968 profileName = testData.getTestDataName();969 }970 if (!testCaseEntityDTO.getIsDataDriven()) {971 if (!databank.isEmpty()) {972 log.info("Test case is not data driven. but has associated test data id");973 int currentIndex = testCaseEntityDTO.getTestDataStartIndex();974 dataSet = databank.get(currentIndex);975 testCaseEntityDTO.setTestDataSetName(dataSet.getName());976 testCaseEntityDTO.setTestDataIndex(currentIndex);977 }978 } else {979 log.info("Test case is data driven...Matching data set with - " + testDataSetName);980 for (int i = 0; i < databank.size(); i++) {981 TestDataSet data = databank.get(i);982 if (data.getName().equals(testDataSetName)) {983 dataSet = data;984 testCaseEntityDTO.setTestDataIndex(i);985 break;986 }987 }988 testCaseEntityDTO.setTestDataSetName(dataSet.getName());989 testCaseEntityDTO.setExpectedToFail(dataSet.getExpectedToFail());990 }991 List<Long> testCaseIds = new ArrayList<>();992 testCaseIds.add(testCaseEntityDTO.getId());993 for (TestStepDTO testStepDTO : testStepDTOS) {994 if (testStepDTO.getStepGroupId() != null) {995 TestCase testCase = testCaseService.find(testStepDTO.getStepGroupId());996 checkTestCaseIsInReadyState(testCase);997 List<TestStep> childSteps;998 childSteps = testStepService.findAllByTestCaseIdAndEnabled(testStepDTO.getStepGroupId());999 List<TestStepDTO> childStepsDTOs = testStepMapper.mapDTOs(childSteps);1000 testStepDTO.setTestStepDTOS(childStepsDTOs);1001 testCaseIds.add(testStepDTO.getStepGroupId());1002 }1003 if (testStepDTO.getAddonActionId() != null) {1004 if (!testDevice.getTestPlanLabType().isHybrid()) {1005 AddonNaturalTextAction addonNaturalTextAction = addonNaturalTextActionService.findById(testStepDTO.getAddonActionId());1006 Addon addon = addonService.findById(addonNaturalTextAction.getAddonId());1007 if (addon.getStatus() == AddonStatus.DRAFT) {1008 throw new TestsigmaException(MessageConstants.DRAFT_PLUGIN_ALLOWED_IN_HYBRID_ONLY,1009 MessageConstants.DRAFT_PLUGIN_ALLOWED_IN_HYBRID_ONLY);1010 }1011 }1012 }1013 }1014 List<String> elementNames = testStepService.findElementNamesByTestCaseIds(testCaseIds);1015 elementNames.addAll(testStepService.findAddonActionElementsByTestCaseIds(testCaseIds));1016 List<Element> elementList = elementService.findByNameInAndWorkspaceVersionId(elementNames,1017 testDevice.getWorkspaceVersionId());1018 Map<String, Element> elements = new HashMap<>();1019 for (Element element : elementList) {1020 elements.put(element.getName().toLowerCase(), element);1021 }1022 if (!testCaseEntityDTO.getIsDataDriven()) {1023 if (!databank.isEmpty()) {1024 dataSet = databank.get(testCaseEntityDTO.getTestDataStartIndex());1025 testCaseEntityDTO.setTestDataSetName(dataSet.getName());1026 }1027 } else {1028 for (TestDataSet data : databank) {1029 if (data.getName().equals(testDataSetName)) {1030 dataSet = data;1031 break;1032 }1033 }1034 testCaseEntityDTO.setTestDataSetName(dataSet.getName());1035 testCaseEntityDTO.setExpectedToFail(dataSet.getExpectedToFail());1036 }1037 List<TestCaseStepEntityDTO> executableList = getExecutableTestSteps(1038 workspace.getWorkspaceType(), testStepDTOS,1039 elements, dataSet, testPlan.getId(),1040 environmentParameters, testCaseEntityDTO, environmentProfileName,1041 profileName,getStepGroupParentForLoopStepIdIndexes(testCaseEntityDTO));1042 appendPreSignedURLs(executableList, testCaseEntityDTO, testDevice,false, null, null);1043 testCaseEntityDTO.setTestSteps(executableList);1044 TestCaseResult testCaseResult = testCaseResultService.find(testCaseEntityDTO.getTestCaseResultId());1045 testCaseResultService.markTestCaseResultAsInProgress(testCaseResult);1046 }1047 private Map<Long, Integer> getStepGroupParentForLoopStepIdIndexes(TestCaseEntityDTO testCaseEntityDTO){1048 Map<Long, Integer> dataIndex = testCaseEntityDTO.getStepGroupParentForLoopStepIdIndexes();1049 if(!testCaseEntityDTO.getIsStepGroup()){1050 dataIndex.put(ParameterTestDataProcessor.OVERRIDE_STEP_GROUP_STEP_WITH_TEST_CASE_PROFILE_ID,1051 testCaseEntityDTO.getTestDataIndex() == null ? 0 : testCaseEntityDTO.getTestDataIndex());1052 }1053 return dataIndex;1054 }1055 private boolean isStepInsideForLoop(TestCaseStepEntityDTO testCaseStepEntity) throws ResourceNotFoundException {1056 if (testCaseStepEntity.getParentId() != null) {1057 TestStep testStep = testStepService.find(testCaseStepEntity.getParentId());1058 return (testStep.getType() == TestStepType.FOR_LOOP);1059 }1060 return false;1061 }1062 protected void appendPreSignedURLs(List<TestCaseStepEntityDTO> executableList, TestCaseEntityDTO testCaseEntity,1063 TestDevice testDevice, boolean isWhileLoop, Long stepGroupStepID, TestCaseStepEntityDTO parentGroupEntity)1064 throws ResourceNotFoundException {1065 Calendar cal = Calendar.getInstance();1066 cal.add(Calendar.HOUR, 10);1067 stepGroupStepID = (stepGroupStepID == null) ? 0 : stepGroupStepID;1068 StorageService storageService = this.storageServiceFactory.getStorageService();1069 for (TestCaseStepEntityDTO testCaseStepEntity : executableList) {1070 Integer index;1071 Long parentId = testCaseStepEntity.getParentId();1072 if(parentId == null)1073 parentId = 0L;1074 int rand =0;1075 if (parentGroupEntity != null && !isStepInsideForLoop(testCaseStepEntity)) {1076 index = (parentGroupEntity.getIndex() == null) ? 0 : parentGroupEntity.getIndex();1077 } else {1078 rand = new Random().ints(1, 100).findFirst().getAsInt();1079 index = (testCaseStepEntity.getIndex() == null) ? 0 : testCaseStepEntity.getIndex();1080 }1081 String screenShotPath = String.format("/executions/%s/%s_%s_%s_%s_%s_%s.%s", testCaseEntity.getTestCaseResultId(),1082 testCaseStepEntity.getId(), stepGroupStepID, parentId, testCaseStepEntity.getPosition(), index, rand ,"jpeg");1083 URL presignedURL = storageService.generatePreSignedURL(screenShotPath, StorageAccessLevel.WRITE, 600);1084 testCaseStepEntity.setScreenshotPath(presignedURL.toString());1085 handleUploadActionStep(testCaseStepEntity,storageService, testDevice);1086 handleInstallApp(testCaseStepEntity,storageService, testDevice);1087 if ((testCaseStepEntity.getTestCaseSteps() != null) && !testCaseStepEntity.getTestCaseSteps().isEmpty()) {1088 if (testCaseStepEntity.getConditionType() == TestStepConditionType.LOOP_WHILE) {1089 addScreenshotPresignedURLsForWhileLoop(testCaseStepEntity, testCaseEntity, stepGroupStepID, parentGroupEntity,storageService);1090 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice,true, stepGroupStepID, parentGroupEntity);1091 } else if (testCaseStepEntity.getType() == TestStepType.STEP_GROUP) {1092 Long parentGroupStepId = (stepGroupStepID != 0) ? stepGroupStepID : testCaseStepEntity.getId();1093 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice, isWhileLoop, parentGroupStepId, testCaseStepEntity);1094 } else {1095 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice, isWhileLoop, stepGroupStepID, parentGroupEntity);1096 }1097 }1098 if (isWhileLoop && !(testCaseStepEntity.getType() == TestStepType.STEP_GROUP)) {1099 addScreenshotPresignedURLsForWhileLoop(testCaseStepEntity, testCaseEntity, stepGroupStepID, parentGroupEntity,storageService);1100 }1101 }1102 }1103 private void addScreenshotPresignedURLsForWhileLoop(TestCaseStepEntityDTO testCaseStep, TestCaseEntityDTO testCaseEntity,1104 Long parentGroupStepId, TestCaseStepEntityDTO parentGroupEntity, StorageService storageService) {1105 parentGroupStepId = (parentGroupStepId == null) ? 0 : parentGroupStepId;1106 Map<String, String> additionalScreenshotPaths = new HashMap<>();1107 for (int iteration = 1; iteration <= NaturalTextActionConstants.WHILE_LOOP_MAX_LIMIT; iteration++) {1108 Calendar cal = Calendar.getInstance();1109 cal.add(Calendar.HOUR, 10);1110 Integer index = null;1111 if (parentGroupEntity != null) {1112 index = (parentGroupEntity.getIndex() == null) ? 0 : parentGroupEntity.getIndex();1113 } else {1114 index = (testCaseStep.getIndex() == null) ? 0 : testCaseStep.getIndex();1115 }1116 String screenShotPath = String.format("/executions/%s/%s_%s_%s_%s_%s.%s", testCaseEntity.getTestCaseResultId(),1117 testCaseStep.getId(), parentGroupStepId, iteration, testCaseStep.getPosition(), index, "jpeg");1118 URL preSignedURL = storageService.generatePreSignedURL(screenShotPath, StorageAccessLevel.WRITE, 600);1119 String iterationKey = String.format("%s_%s", iteration, testCaseStep.getIndex());1120 additionalScreenshotPaths.put(iterationKey, preSignedURL.toString());1121 }1122 testCaseStep.setAdditionalScreenshotPaths(additionalScreenshotPaths);1123 }1124 private void handleUploadActionStep(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1125 if (testCaseStepEntity.getAction() != null && testCaseStepEntity.getAction().toLowerCase().contains("upload")1126 && testCaseStepEntity.getNaturalTextActionId() != null && (testCaseStepEntity.getNaturalTextActionId().equals(969)1127 || testCaseStepEntity.getNaturalTextActionId().equals(10150))) {1128 handleFileActionStep(testCaseStepEntity,storageService, testDevice);1129 }1130 }1131 private void handleInstallApp(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1132 if (testCaseStepEntity.getAction() != null && testCaseStepEntity.getAction()1133 .toLowerCase().contains("installApp".toLowerCase()) && (testCaseStepEntity.getNaturalTextActionId() != null)1134 && (testCaseStepEntity.getNaturalTextActionId().equals(20003) || testCaseStepEntity.getNaturalTextActionId().equals(30003))) {1135 handleFileActionStep(testCaseStepEntity,storageService, testDevice);1136 }1137 }1138 private void handleFileActionStep(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1139 com.testsigma.automator.entity.TestDataPropertiesEntity testDataPropertiesEntity = testCaseStepEntity.getTestDataMap().get(1140 testCaseStepEntity.getTestDataMap().keySet().stream().findFirst().get());1141 String fileUrl = testDataPropertiesEntity.getTestDataValue().replace("testsigma-storage://", "");1142 URL newUrl = storageService.generatePreSignedURL(fileUrl, StorageAccessLevel.READ, 180);1143 if(TestPlanLabType.TestsigmaLab == testDevice.getTestPlanLabType()) {1144 try {1145 newUrl = new URL(newUrl.toString().replace(applicationConfig.getServerUrl(), applicationConfig.getServerLocalUrl()));1146 } catch (MalformedURLException ignore) {}1147 }1148 testDataPropertiesEntity.setTestDataValuePreSignedURL(newUrl.toString());1149 }1150 private void setPlatformDetails(TestDevice testDevice, TestDeviceSettings settings,1151 TestPlanLabType testPlanLabType, Agent agent,EnvironmentEntityDTO environmentEntityDTO) throws TestsigmaException {1152 populatePlatformOsDetails(testDevice, settings, testPlanLabType, agent);1153 if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isWeb()) {1154 populatePlatformBrowserDetails(testDevice, settings, testPlanLabType, agent,environmentEntityDTO);1155 }1156 }1157 protected void populatePlatformOsDetails(TestDevice testDevice, TestDeviceSettings settings,1158 TestPlanLabType testPlanLabType, Agent agent)1159 throws TestsigmaException {1160 PlatformOsVersion platformOsVersion = null;1161 if (testPlanLabType == TestPlanLabType.Hybrid) {1162 Platform platform = null;1163 String osVersion = null;1164 if ((testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isWeb()) && agent != null) {1165 platform = agent.getOsType().getPlatform();1166 osVersion = agent.getPlatformOsVersion(agent.getOsType().getPlatform());1167 } else if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isMobile() && testDevice.getDeviceId() != null) {1168 AgentDevice agentDevice = this.agentDeviceService.find(testDevice.getDeviceId());1169 osVersion = agentDevice.getPlatformOsVersion();1170 platform = agentDevice.getOsName().getPlatform();1171 }1172 platformOsVersion = platformsService.getPlatformOsVersion(platform, osVersion, testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType(), testPlanLabType);1173 }1174 else {1175 platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testPlanLabType);1176 }1177 if (testPlanLabType != TestPlanLabType.PrivateGrid)1178 settings.setPlatform(platformOsVersion.getPlatform());1179 else1180 settings.setPlatform(testDevice.getPlatform());1181 if (TestPlanLabType.Hybrid == testPlanLabType) {...

Full Screen

Full Screen

Source:Platform.java Github

copy

Full Screen

...17 Android("Android", ""),18 iOS("iOS", "");19 private final String os;20 private final String versionPrefix;21 public Boolean isMobile() {22 return this == Platform.Android || this == Platform.iOS;23 }24}...

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

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

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.Platform;2import com.testsigma.model.Device;3import com.testsigma.model.DeviceManager;4import com.testsigma.model.DeviceManagerFactory;5import com.testsigma.model.DeviceManagerException;6import com.testsigma.model.DeviceManagerException;7import com.testsigma.model.DeviceManagerFactory;8import com.testsigma.model.DeviceManagerFactory;9import com.testsigma.model.DeviceManagerException;10import com.testsigma.model.DeviceManagerException;11import com.testsigma.model.DeviceManagerFactory;12import com.testsigma.model.DeviceManagerFactory;13import com.testsigma.model.DeviceManagerException;14import com.testsigma.model.DeviceManagerException;15import com.testsigma.model.DeviceManagerFactory;16import com.testsigma.model.DeviceManagerFactory;17import com.testsigma.model.DeviceManagerException;18import com.testsigma.model.DeviceManagerException;19import com.testsigma.model.DeviceManagerFactory;20import com.testsigma.model.DeviceManagerFactory;21import com.testsigma.model.DeviceManagerException;22import com.testsigma.model.DeviceManagerException;23import com.testsigma.model.DeviceManagerFactory;24import com.testsigma.model.DeviceManagerFactory;25import com.testsigma.model.DeviceManagerException;26import com.testsigma.model.DeviceManagerException;27import com.testsigma.model.DeviceManagerFactory;28import com.testsigma.model.DeviceManagerFactory;29import com.testsigma.model.DeviceManagerException;30import com.testsigma.model.DeviceManagerException;31import com.testsigma.model.DeviceManagerFactory;32import com.testsigma.model.DeviceManagerFactory;33import com.testsigma.model.DeviceManagerException;34import com.testsigma.model.DeviceManagerException;35import com.testsigma.model.DeviceManagerFactory;36import com.testsigma.model.DeviceManagerFactory;37import com.testsigma.model.DeviceManagerException;38import com.testsigma.model.DeviceManagerException;39import com.testsigma.model.DeviceManagerFactory;40import com.testsigma.model.DeviceManagerFactory;41import com.testsigma.model.DeviceManagerException;42import com.testsigma.model.DeviceManagerException;43import com.testsigma.model.DeviceManagerFactory;44import com.testsigma.model.DeviceManagerFactory;45import com.testsigma.model.DeviceManagerException;46import com.testsigma.model.DeviceManagerException;47import com.testsigma.model.DeviceManagerFactory;48import com.testsigma.model.DeviceManagerFactory;49import com.testsigma.model.DeviceManagerException;50import com.testsigma.model.DeviceManagerException;51import com.testsigma.model.DeviceManagerFactory;52import com.testsigma.model.DeviceManagerFactory;53import com.testsigma.model.DeviceManagerException;54import com.testsigma.model.DeviceManagerException;55import com

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.Platform;2public class 2 {3 public static void main(String[] args) {4 System.out.println("Is Mobile: " + Platform.isMobile());5 }6}7import com.testsigma.model.Platform;8public class 3 {9 public static void main(String[] args) {10 System.out.println("Is Mobile: " + Platform.isMobile());11 }12}13import com.testsigma.model.Platform;14public class 4 {15 public static void main(String[] args) {16 System.out.println("Is Mobile: " + Platform.isMobile());17 }18}19import com.testsigma.model.Platform;20public class 5 {21 public static void main(String[] args) {22 System.out.println("Is Mobile: " + Platform.isMobile());23 }24}25import com.testsigma.model.Platform;26public class 6 {27 public static void main(String[] args) {28 System.out.println("Is Mobile: " + Platform.isMobile());29 }30}31import com.testsigma.model.Platform;32public class 7 {33 public static void main(String[] args) {34 System.out.println("Is Mobile: " + Platform.isMobile());35 }36}

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

1public class TestMobile {2 public static void main(String[] args) {3 Platform platform = new Platform();4 System.out.println("Is Mobile? " + platform.isMobile());5 }6}7public class TestMobile {8 public static void main(String[] args) {9 Platform platform = new Platform();10 System.out.println("Is Mobile? " + platform.isMobile());11 }12}13public class TestMobile {14 public static void main(String[] args) {15 Platform platform = new Platform();16 System.out.println("Is Mobile? " + platform.isMobile());17 }18}19public class TestMobile {20 public static void main(String[] args) {21 Platform platform = new Platform();22 System.out.println("Is Mobile? " + platform.isMobile());23 }24}25public class TestMobile {26 public static void main(String[] args) {27 Platform platform = new Platform();28 System.out.println("Is Mobile? " + platform.isMobile());29 }30}31public class TestMobile {32 public static void main(String[] args) {33 Platform platform = new Platform();34 System.out.println("Is Mobile? " + platform.isMobile());35 }36}37public class TestMobile {38 public static void main(String[] args) {39 Platform platform = new Platform();40 System.out.println("Is Mobile? " + platform.isMobile());41 }42}43public class TestMobile {44 public static void main(String[] args) {45 Platform platform = new Platform();46 System.out.println("Is Mobile? " + platform.isMobile());47 }48}49public class TestMobile {

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.Platform;2import com.testsigma.model.PlatformType;3{4public static void main(String[] args)5{6Platform platform = new Platform();7platform.setPlatform(PlatformType.ANDROID);8boolean isMobile = platform.isMobile();9if(isMobile)10{11System.out.println("Platform is mobile");12}13{14System.out.println("Platform is not mobile");15}16}17}18import com.testsigma.model.Platform;19import com.testsigma.model.PlatformType;20{21public static void main(String[] args)22{23Platform platform = new Platform();24platform.setPlatform(PlatformType.IOS);25boolean isMobile = platform.isMobile();26if(isMobile)27{28System.out.println("Platform is mobile");29}30{31System.out.println("Platform is not mobile");32}33}34}35import com.testsigma.model.Platform;36import com.testsigma.model.PlatformType;37{38public static void main(String[] args)39{40Platform platform = new Platform();41platform.setPlatform(PlatformType.WINDOWS);42boolean isMobile = platform.isMobile();43if(isMobile)44{45System.out.println("Platform is mobile");46}47{48System.out.println("Platform is not mobile");49}50}51}52import com.testsigma.model.Platform;53import com.testsigma.model.PlatformType;54{55public static void main(String[] args)56{57Platform platform = new Platform();58platform.setPlatform(PlatformType.LINUX);59boolean isMobile = platform.isMobile();60if(isMobile)61{62System.out.println("Platform is

Full Screen

Full Screen

isMobile

Using AI Code Generation

copy

Full Screen

1@Test(groups = { "android" })2public void test2() {3 if (Platform.isMobile("android")) {4 }5}6@Test(groups = { "android" })7public void test3() {8 if (Platform.isMobile("android")) {9 }10}11@Test(groups = { "android" })12public void test4() {13 if (Platform.isMobile("android")) {14 }15}16@Test(groups = { "android" })17public void test5() {18 if (Platform.isMobile("android")) {19 }20}21@Test(groups = { "android" })22public void test6() {23 if (Platform.isMobile("android")) {24 }25}

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Testsigma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Platform

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful