Selenium webdriver 在saucelabs Windows7中运行selenium测试

Selenium webdriver 在saucelabs Windows7中运行selenium测试,selenium-webdriver,saucelabs,Selenium Webdriver,Saucelabs,我正在尝试运行一个简单的测试,看看是否可以使用以下功能运行 OS: Windows 7 Browser: Firefox Browser Version: 33 这是我的密码: import static org.junit.Assert.*; import java.net.URL; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.Web

我正在尝试运行一个简单的测试,看看是否可以使用以下功能运行

OS: Windows 7
Browser: Firefox
Browser Version: 33
这是我的密码:

import static org.junit.Assert.*;

import java.net.URL;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Tests {

    private WebDriver driver;

    @Before
    public void setUp() throws Exception {
        // Choose the browser, version, and platform to test
        DesiredCapabilities caps = DesiredCapabilities.firefox();
        caps.setCapability("platform", "Windows 7");
        caps.setCapability("version", "33");
        caps.setCapability("browserName", "");
        // Create the connection to Sauce Labs to run the tests
        this.driver = new RemoteWebDriver(
                new URL("http://<axxxxxx>:<5xxxxx@ondemand.saucelabs.com:80/wd/hub"),
                caps);
    }

    @Test
    public void webDriver() throws Exception {
        // Make the browser get the page and check its title
        driver.get("http://www.amazon.com/");
        assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle());
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
    }
}

我很困惑。该网站称支持Windows7。我哪里出错了?

如下定义功能解决了我的问题。在平台上观察VISTA

DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("version", "33"); 
capabilities.setCapability("platform", Platform.VISTA); 
capabilities.setCapability("name", "Windows7Firefox33");

您在Selenium 2.44.0中遇到了一个错误。正如酱油实验室知识库中指出的,您有两个选择:

  • 根据本文,首选选项是恢复到2.43.0。

  • 您选择的选项:使用
    平台
    枚举中的一个值,而不是
    字符串
    。(事实证明,至少有一段时间不可能使用此选项,但酱汁实验室的人修改了他们的终端以允许它。)


  • 文章还指出,下一个版本的Selenium将有必要的修复。

    您可以在setCapability中使用
    平台.WINDOWS
    吗?您使用的是什么版本的Selenium?如果您使用的是2.43.0,这是Sauce Labs支持的最新版本,它能工作吗?看起来我需要说平台是VISTA,那么它在Windows7上运行。DesiredCapabilities=DesiredCapabilities.firefox();能力。设置能力(“版本”、“33”);能力.setCapability(“平台”,platform.VISTA);setCapability(“名称”、“Windows7Firefox33”)@维维克辛格,如果我试过这个选择。如果我说Platform.WINDOWS,它将在哪个WINDOWS操作系统中运行。当我尝试这一点时,默认情况下它使用的是XP。我希望我的测试在Windows 7上运行。@Louis,我正在使用2.44.0 selenium。然而,我不得不把这个平台做成“VISTA”。现在它运行在Windows7上,硒的问题是
    DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
    capabilities.setCapability("version", "33"); 
    capabilities.setCapability("platform", Platform.VISTA); 
    capabilities.setCapability("name", "Windows7Firefox33");