Have spent over 8 hours trying trying to fix this problem with zero success. I want to start and stop docker desktop programmatically. I know it's possible as a window user but I cannot find any how to do this with mac operating system (I have checked). I found something that might work but there I are elements of the java code with Selenium Grid I don't understand. It might be ignorance on my part as a novice but I just want to fix this as I'm sure it's simple.
I decided to run the code anyway because I could find a solution if I understood the error message. I ran the code it failed but I got no error message.
I'm a novice with Selenium Grid with Java so any feedback will be appreciated.
this is piece of code I seem to be having a problem with.
The user.dir seems to be mean some sort of user directory? But what directory are they specifically talking about? I have no idea.
I will show a snippet 1st and then the full code.
public class TestBase {
private static final String SETUP_DOCKER_SCRIPT_FILE = System.getProperty("user.dir") + "/dockerup.sh";
private static final String SCALE_CHROME_FILE = System.getProperty("user.dir") + "/docker_scale.sh";
private static final String TEAR_DOWN_SCRIPT_FILE = System.getProperty("user.dir") + "/dockerdown.sh";
private static final String EXPECTED_MESSAGE = "The node is registered to the hub and ready to use";
public static ThreadLocal<RemoteWebDriver> remoteWebDriver = new ThreadLocal<RemoteWebDriver>();
Here is the code in full:
package remoteTesting.dockerValidation1;
import static utils.StartStopDockerContainer.execute;//this is a imported file from the utils package
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
public class TestBase {
private static final String SETUP_DOCKER_SCRIPT_FILE = System.getProperty("user.dir") + "/dockerup.sh";
private static final String SCALE_CHROME_FILE = System.getProperty("user.dir") + "/docker_scale.sh";
private static final String TEAR_DOWN_SCRIPT_FILE = System.getProperty("user.dir") + "/dockerdown.sh";
private static final String EXPECTED_MESSAGE = "The node is registered to the hub and ready to use";
public static ThreadLocal<RemoteWebDriver> remoteWebDriver = new ThreadLocal<RemoteWebDriver>();
@BeforeSuite
public void setUp() {
execute(SETUP_DOCKER_SCRIPT_FILE, EXPECTED_MESSAGE);
execute(SCALE_CHROME_FILE, true);
}
@BeforeClass
public void beforeTest() throws Exception {
URL url = new URL("http://localhost:4444/wd/hub");
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
remoteWebDriver.set(new RemoteWebDriver(url, desiredCapabilities));
}
@AfterClass
public void tearDown() {
remoteWebDriver.get().close();
}
@AfterSuite
public void afterTest() {
execute(TEAR_DOWN_SCRIPT_FILE, true);
}
}