【发布时间】:2015-01-09 02:03:19
【问题描述】:
我正在尝试运行一个简单的测试,看看我是否可以使用以下功能运行。
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();
}
}
当我运行此测试时,我似乎无法使用 Windows 7:
java.lang.IllegalArgumentException: No enum constant org.openqa.selenium.Platform.Windows 7
at java.lang.Enum.valueOf(Enum.java:236)
at org.openqa.selenium.Platform.valueOf(Platform.java:30)
at org.openqa.selenium.remote.DesiredCapabilities.setCapability(DesiredCapabilities.java:168)
我很困惑。网站http://docs.seleniumhq.org/about/platforms.jsp 表示支持 Windows 7。我在哪里做错了?
【问题讨论】:
-
你可以尝试在 setCapability 中使用
Platform.WINDOWS吗? -
您使用的是什么版本的 Selenium?如果您使用 2.43.0,这是 Sauce Labs 列出的支持的最新版本,它可以工作吗?
-
看来我需要说平台为VISTA,然后它在Windows7上运行。DesiredCapabilities能力= DesiredCapabilities.firefox();能力.setCapability(“版本”,“33”);能力.setCapability(“平台”,Platform.VISTA); capabilities.setCapability("name", "Windows7Firefox33");
-
@VivekSingh,如果我尝试了该选项。如果我说 Platform.WINDOWS,它将在哪个 Windows 操作系统中运行。当我尝试这个时,默认情况下它使用的是 XP。我希望我的测试在 Windows 7 上运行。
-
@Louis,我使用的是 2.44.0 硒。但是,我不得不将平台设为“VISTA”。现在它可以在 Windows7 上运行
标签: selenium-webdriver saucelabs