我想运行一个简单的测试,看看我是否可以使用下面的功能运行。在saucelabs中运行硒测试Windows7
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>:<[email protected]ndemand.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支持的最新版本,它的工作原理是什么? – Louis
它看起来像我需要说的平台作为VISTA,然后它运行在Windows7.DesiredCapabilities功能= DesiredCapabilities.firefox(); capabilities.setCapability(“version”,“33”); capabilities.setCapability(“platform”,Platform.VISTA);功能.setCapability(“name”,“Windows7Firefox33”); –