Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用Java TestNG Selenium Grid在Mac OS中以编程方式启动docker_Java_Docker_Automated Tests_Selenium Grid - Fatal编程技术网

无法使用Java TestNG Selenium Grid在Mac OS中以编程方式启动docker

无法使用Java TestNG Selenium Grid在Mac OS中以编程方式启动docker,java,docker,automated-tests,selenium-grid,Java,Docker,Automated Tests,Selenium Grid,我花了8个多小时试图解决这个问题,但没有成功。我想以编程方式启动和停止docker desktop。我知道作为一个窗口用户这是可能的,但是我找不到任何方法来使用mac操作系统(我已经检查过了)。我发现了一些可能有用的东西,但我不了解Selenium网格的java代码元素。这可能是我作为一个新手的无知,但我只是想解决这个问题,因为我确信它很简单 我决定无论如何都要运行代码,因为如果我理解错误消息,我可以找到解决方案。我运行了代码,但失败了,但没有收到错误消息 我是使用Java的Selenium G

我花了8个多小时试图解决这个问题,但没有成功。我想以编程方式启动和停止docker desktop。我知道作为一个窗口用户这是可能的,但是我找不到任何方法来使用mac操作系统(我已经检查过了)。我发现了一些可能有用的东西,但我不了解Selenium网格的java代码元素。这可能是我作为一个新手的无知,但我只是想解决这个问题,因为我确信它很简单

我决定无论如何都要运行代码,因为如果我理解错误消息,我可以找到解决方案。我运行了代码,但失败了,但没有收到错误消息

我是使用Java的Selenium Grid的新手,因此任何反馈都将不胜感激

这是一段我似乎有问题的代码

user.dir似乎是指某种用户目录?但他们具体谈论的是什么目录?我不知道。

我将首先显示一段代码片段,然后显示完整的代码

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>();
公共类测试库{
私有静态最终字符串设置\u DOCKER\u SCRIPT\u FILE=System.getProperty(“user.dir”)+“/dockrup.sh”;
私有静态最终字符串SCALE\u CHROME\u FILE=System.getProperty(“user.dir”)+“/docker\u SCALE.sh”;
private static final String TEAR_DOWN_SCRIPT_FILE=System.getProperty(“user.dir”)+“/dockerdown.sh”;
应为私有静态最终字符串\u MESSAGE=“节点已注册到集线器并准备好使用”;
public static ThreadLocal remoteWebDriver=new ThreadLocal();
以下是完整的代码:

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);
        }
}
package remoteTesting.dockerValidation1;
导入静态utils.StartStopDockerContainer.execute;//这是从utils包导入的文件
导入java.net.URL;
导入org.openqa.selenium.remote.DesiredCapabilities;
导入org.openqa.selenium.remote.RemoteWebDriver;
导入org.testng.annotations.AfterClass;
导入org.testng.annotations.AfterSuite;
导入org.testng.annotations.BeforeClass;
导入org.testng.annotations.BeforeSuite;
公共类测试库{
私有静态最终字符串设置\u DOCKER\u SCRIPT\u FILE=System.getProperty(“user.dir”)+“/dockrup.sh”;
私有静态最终字符串SCALE\u CHROME\u FILE=System.getProperty(“user.dir”)+“/docker\u SCALE.sh”;
private static final String TEAR_DOWN_SCRIPT_FILE=System.getProperty(“user.dir”)+“/dockerdown.sh”;
应为私有静态最终字符串\u MESSAGE=“节点已注册到集线器并准备好使用”;
public static ThreadLocal remoteWebDriver=new ThreadLocal();
@套房前
公共作废设置(){
执行(设置\u DOCKER\u脚本\u文件,预期\u消息);
执行(SCALE\u CHROME\u文件,true);
}
@课前
public void beforeTest()引发异常{
URL=新URL(“http://localhost:4444/wd/hub");
DesiredCapabilities DesiredCapabilities=DesiredCapabilities.chrome();
set(新的remoteWebDriver(url,desiredCapabilities));
}
@下课
公共无效拆卸(){
remoteWebDriver.get().close();
}
@事后
公开无效后验(){
执行(撕下脚本文件,true);
}
}