井。这不是问题。我想分享我如何解决这个问题。我得到了安装了jdk的VM(虚拟机),并在VM上运行硒服务器。VM 具有 IP:192.168.4.52 我已通过(RDC-远程桌面连接)连接到它。在其上安装了所需的浏览器(火狐15)。打开浏览器。已禁用所有更新和其他弹出窗口。
我在本地机器上有硒测试包。我在我的 VM 上运行它们。硒设置如下:
import com.google.common.base.Function;
import com.thoughtworks.selenium.SeleneseTestBase;
import junit.framework.Assert;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
public class BaseSeleniumTest extends SeleneseTestBase {
    static WebDriver driver;
    @Value("login.base.url")
    private String loginBaseUrl;
    @BeforeClass
    public static void firefoxSetUp() throws MalformedURLException {
//        DesiredCapabilities capability = DesiredCapabilities.firefox();
        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        driver = new RemoteWebDriver(new URL("http://192.168.4.52:4444/wd/hub"), capability);
//        driver = new FirefoxDriver();  //for local check
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        driver.manage().window().setSize(new Dimension(1920, 1080));
    }
    @Before
    public void openFiretox() throws IOException {
        driver.get(propertyKeysLoader("login.base.url"));
    }
    @AfterClass
    public static void closeFirefox(){
        driver.quit();
    }
.....
这段代码将在远程计算机上运行所有硒测试。在字符串中,您只需提及计算机的IP,这应该有效。driver = new RemoteWebDriver(new URL("http://192.168.4.52:4444/wd/hub"), capability);
希望这对您有所帮助。