2017-01-03 106 views

回答

1

如果你的要求是要测试你的网站在移动视图(如您的网站响应),则下面的代码可以帮助你 -

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(30, TimeUnit.SECONDS); 
driver.manage().window().setSize(new Dimension(360,640)); //just to change the window size so that it will look like mobile 
driver.get(siteURL); 
1

您可以使用Appium支持

手机Web应用程序是使用移动浏览器访问的Web应用程序(Appium支持iOS和Chrome上的Safari或Android上内置的“浏览器”应用程序)。

它的设计基于WebDriver API,因此您可以自由使用您已拥有的任何测试运行器和测试框架。牢记这一点,您当前的Test engine应该对应用程序驱动程序不敏感,并且这些只是插入&无论如何播放“自动化库”。

这是我喜欢使用的Appium GitHub examples repo。你可以找到例子:

  • RobotFramework
  • DOTNET
  • 的Java
  • 节点
  • perl的
  • PHP
  • 蟒蛇
  • 红宝石