我想運行一個簡單的測試,看看我是否可以使用下面的功能運行。在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」); –