Skip to content

Commit

Permalink
Change the remote to webdrivermanager also
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Aug 3, 2024
1 parent f746f98 commit cf2b880
Showing 1 changed file with 34 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

package com.fullteaching.e2e.no_elastest.common;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.net.MalformedURLException;
Expand Down Expand Up @@ -68,42 +67,39 @@ public ChromeUser(String userName, int timeOfWaitInSeconds, String testName, Str
log.info("Using the Local WebDriver ()");
this.driver = new ChromeDriver(options);
} else {
try {

Map<String, Object> selenoidOptions = new HashMap<>();
log.info("Using the remote WebDriver (Selenoid)");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm");
log.debug("Adding all the extra capabilities needed: {testName,enableVideo,enableVNC,name,enableLog,videoName,screenResolution}");

selenoidOptions.put("testName", testName + "_" + userIdentifier + "_" + format.format(new Date()));
//CAPABILITIES FOR SELENOID RETORCH
selenoidOptions.put("enableVideo", true);
selenoidOptions.put("enableVNC", true);
selenoidOptions.put("name", testName + "-" + userIdentifier);

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yy-MM-dd-HH:mm");
LocalDateTime now = LocalDateTime.now();
String logName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".log";
String videoName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".mp4";
log.debug("The data of this test would be stored into: video name " + videoName + " and the log is " + logName);

selenoidOptions.put("enableLog", true);
selenoidOptions.put("logName ", logName);
selenoidOptions.put("videoName", videoName);

selenoidOptions.put("screenResolution", "1920x1080x24");

options.setCapability("selenoid:options", selenoidOptions);

//END CAPABILITIES FOR SELENOID RETORCH
log.debug("Configuring the remote WebDriver ");
RemoteWebDriver remote = new RemoteWebDriver(new URL("http://selenoid:4444/wd/hub"), options);
log.debug("Configuring the Local File Detector");
remote.setFileDetector(new LocalFileDetector());
this.driver = remote;
} catch (MalformedURLException e) {
throw new RuntimeException("Exception creating eusApiURL", e);
}

Map<String, Object> selenoidOptions = new HashMap<>();
log.info("Using the remote WebDriver (Selenoid)");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm");
log.debug("Adding all the extra capabilities needed: {testName,enableVideo,enableVNC,name,enableLog,videoName,screenResolution}");

selenoidOptions.put("testName", testName + "_" + userIdentifier + "_" + format.format(new Date()));
//CAPABILITIES FOR SELENOID RETORCH
selenoidOptions.put("enableVideo", true);
selenoidOptions.put("enableVNC", true);
selenoidOptions.put("name", testName + "-" + userIdentifier);

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yy-MM-dd-HH:mm");
LocalDateTime now = LocalDateTime.now();
String logName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".log";
String videoName = System.getProperty("tjob_name") + "-" + dtf.format(now) + "-" + testName + "-" + userIdentifier + ".mp4";
log.debug("The data of this test would be stored into: video name: '{}' and the log name is '{}' ",videoName,logName);

selenoidOptions.put("enableLog", true);
selenoidOptions.put("logName ", logName);
selenoidOptions.put("videoName", videoName);

selenoidOptions.put("screenResolution", "1920x1080x24");

options.setCapability("selenoid:options", selenoidOptions);

//END CAPABILITIES FOR SELENOID RETORCH
log.debug("Configuring the remote WebDriver ");
driver= WebDriverManager.chromedriver().remoteAddress("http://selenoid:4444/wd/hub").capabilities(options).create();
//RemoteWebDriver remote = new RemoteWebDriver(new URL("http://selenoid:4444/wd/hub"), options);
//log.debug("Configuring the Local File Detector");
//driver.setFileDetector(new LocalFileDetector());
//this.driver = remote;
}
log.debug("Configure the driver connection timeouts at ({})", this.timeOfWaitInSeconds);
new WebDriverWait(driver, Duration.ofSeconds(this.timeOfWaitInSeconds));
Expand Down

0 comments on commit cf2b880

Please sign in to comment.