我有以下代码通过更改用户代理在我的桌面的Firefox中打开Facebook的移动版本。
@Test
public void fb() {
FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference("general.useragent.override", "iPhone"); //this will change the user agent which will open mobile browser
WebDriver driver = new FirefoxDriver(ffprofile);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(400,800)); //just to change the window size so that it will look like mobile ;)
driver.navigate().to("http://www.facebook.com/");
driver.findElement(By.name("email")).sendKeys("username");
driver.findElement(By.name("pass")).sendKeys("************");
driver.findElement(By.name("login")).click();
}
但由于某种原因,它看起来似乎并不合适。谁能让我知道我在这里做错了什么?