Best Testsigma code snippet using com.testsigma.automator.drivers.DriversUpdateService.DriversUpdateService
Source:DriversUpdateService.java
...16import java.util.Map;17import java.util.zip.ZipEntry;18import java.util.zip.ZipInputStream;19@Log4j220public class DriversUpdateService {21 public static final String BROWSER_STR = "browser";22 public static final String VERSION_STR = "version";23 private final String driversFolderPath;24 private final String osType;25 public DriversUpdateService() {26 driversFolderPath = PathUtil.getInstance().getDriversPath();27 osType = new OsUtil().getOsType();28 }29 public static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {30 File destFile = new File(destinationDir, zipEntry.getName());31 String destDirPath = destinationDir.getCanonicalPath();32 String destFilePath = destFile.getCanonicalPath();33 if (!destFilePath.startsWith(destDirPath + File.separator)) {34 throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());35 }36 return destFile;37 }38 public void syncBrowserDriver(TestDeviceEntity testDeviceEntity) throws AutomatorException {39 if (testDeviceEntity.getExecutionLabType() == ExecutionLabType.Hybrid) {...
Source:EnvironmentRunner.java
1package com.testsigma.automator.runners;2import com.testsigma.automator.constants.ExecutionStatus;3import com.testsigma.automator.constants.AutomatorMessages;4import com.testsigma.automator.drivers.DriversUpdateService;5import com.testsigma.automator.entity.*;6import com.testsigma.automator.exceptions.AutomatorException;7import com.testsigma.automator.exceptions.TestsigmaNoParallelRunException;8import com.testsigma.automator.http.HttpClient;9import com.testsigma.automator.utilities.ErrorUtil;10import com.testsigma.automator.utilities.PathUtil;11import com.testsigma.automator.utilities.ScreenCaptureUtil;12import lombok.Data;13import lombok.extern.log4j.Log4j2;14import org.apache.commons.io.FileUtils;15import org.apache.logging.log4j.ThreadContext;16import java.io.File;17import java.io.IOException;18import java.nio.file.Paths;19@Log4j220@Data21public abstract class EnvironmentRunner {22 protected static final ThreadLocal<ExecutionStatus> executionStatus = new ThreadLocal<>();23 protected static final ThreadLocal<TestDeviceEntity> _runnerEnvironmentEntity = new ThreadLocal<>();24 protected static final ThreadLocal<EnvironmentRunResult> _runnerEnvironmentRunResult = new ThreadLocal<>();25 protected static final ThreadLocal<String> _runnerExecutionId = new ThreadLocal<>();26 protected static final ThreadLocal<HttpClient> _webAppHttpClient = new ThreadLocal<>();27 protected static final ThreadLocal<HttpClient> _assetsHttpClient = new ThreadLocal<>();28 protected TestDeviceEntity testDeviceEntity;29 protected EnvironmentRunResult environmentRunResult;30 protected String testPlanId;31 protected WorkspaceType workspaceType;32 public EnvironmentRunner(TestDeviceEntity testDeviceEntity, EnvironmentRunResult environmentRunResult, HttpClient webAppHttpClient,33 HttpClient assetsHttpClient) {34 this.testDeviceEntity = testDeviceEntity;35 this.environmentRunResult = environmentRunResult;36 this.workspaceType = testDeviceEntity.getWorkspaceType();37 this.testPlanId = getTestPlanId();38 _webAppHttpClient.set(webAppHttpClient);39 _assetsHttpClient.set(assetsHttpClient);40 testDeviceEntity.getEnvSettings().setExecutionRunId(testDeviceEntity.getExecutionRunId());41 testDeviceEntity.getEnvSettings().setOs(this.getOs());42 }43 public static ExecutionStatus getExecutionStatus() {44 return executionStatus.get();45 }46 public static boolean isRunning() {47 return executionStatus.get() == ExecutionStatus.STARTED;48 }49 public static void setStartedStatus() {50 executionStatus.set(ExecutionStatus.STARTED);51 }52 public static void setStoppedStatus() {53 executionStatus.set(ExecutionStatus.STOPPED);54 }55 public static TestDeviceEntity getRunnerEnvironmentEntity() {56 return _runnerEnvironmentEntity.get();57 }58 public static void setRunnerEnvironmentEntity(TestDeviceEntity testDeviceEntity) {59 _runnerEnvironmentEntity.set(testDeviceEntity);60 }61 public static EnvironmentRunResult getRunnerEnvironmentRunResult() {62 return _runnerEnvironmentRunResult.get();63 }64 public static void setRunnerEnvironmentRunResult(EnvironmentRunResult environmentRunResult) {65 _runnerEnvironmentRunResult.set(environmentRunResult);66 }67 public static String getRunnerExecutionId() {68 return _runnerExecutionId.get();69 }70 public static void setRunnerExecutionId(String testPlanId) {71 _runnerExecutionId.set(testPlanId);72 }73 public static HttpClient getWebAppHttpClient() {74 return _webAppHttpClient.get();75 }76 public static HttpClient getAssetsHttpClient() {77 return _assetsHttpClient.get();78 }79 protected void beforeExecute() throws AutomatorException {80 checkForEmptyEnvironment();81 new ScreenCaptureUtil().createScreenshotsFolder();82 new ErrorUtil().checkError(testDeviceEntity.getErrorCode(), null);83 new DriversUpdateService().syncBrowserDriver(testDeviceEntity);84 }85 public EnvironmentRunResult run() {86 try {87 populateThreadContextData();88 setRunnerEnvironmentEntity(testDeviceEntity);89 setRunnerEnvironmentRunResult(environmentRunResult);90 setRunnerExecutionId(testPlanId);91 beforeExecute();92 setStartedStatus();93 execute();94 afterExecute();95 setEnvironmentResult();96 setStoppedStatus();97 } catch (TestsigmaNoParallelRunException e){...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!