2017-01-03 73 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
  • 蟒蛇
  • 紅寶石