問題描述
我正在使用 selenium webdriver 進行 AUT(被測應用程序)的功能測試自動化.AUT 是響應式網絡,我幾乎完成了桌面瀏覽器的不同測試用例.
I am using selenium webdriver for functional test automation of AUT (Application Under Test). AUT is responsive web and i am almost done with different test case for desktop browser.
現在相同的測試用例也適用于移動瀏覽器,因為可以從移動瀏覽器訪問 AUT.因為當我們在移動瀏覽器中打開時它是響應式網絡,所以 UI 有一些不同的表示.所以我們也需要為移動瀏覽器運行這些測試.對于使用 safari 瀏覽器的用戶代理功能的手動測試團隊
Now the same test cases are applicable for mobile browser as well because the AUT can be accessed from mobile browser. As it is responsive web when we open in mobile browser the UI has some different representation. So we need to run those test for mobile browsers as well. For manual testing team using safari browser's user agent feature
Safari瀏覽器菜單->開發->用戶代理
Safari Browser menu - > Develop -> User Agent
它滿足了我們手動測試的需求.
and it satisfies our need for manual testing.
如果我們可以用自動化來做類似的事情,即用一些 twik 在桌面瀏覽器上運行測試,那么它也可以被認為是移動網絡自動化完成.我的問題是如何在使用 Web 驅動程序時做同樣的事情,比如修改標題.url 相同,因為只有一個 web 應用程序.
If we can do the similar thing with automation, i.e. running test on desktop browser with some twik, then it is also accepted to considered as mobile web automation done. My question is how can i do the same thing like modify header, while using web driver. The url is the same because there is only one web app.
我的自動化測試在使用 FirefoxDriver 和 chromeDriver 的 Firefox 上運行良好.兩種瀏覽器都有類似的開發工具可用,但我無法通過自動化來使用它.
My automated test are working fine on firefox using FirefoxDriver and chromeDriver. Both browser has similar development tools available but i am not able to utilise it through automation.
我們使用的是 selenium 2.53.0.我們的 IVY 文件有以下與 selenium 相關的依賴項.
We are using selenium 2.53.0. Our IVY file has following dependencies related to selenium.
<dependency org="org.seleniumhq.selenium" name="selenium-remote-driver" rev="2.53.0"/>
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="2.53.0"/>
任何人都可以提供建議和幫助,我如何運行我的測試來實現它以及我需要做哪些相關的代碼更改?
Can anybody provide suggestions and help that how can i run my test to achieve it and what are the related code changes i need to do?
謝謝.
推薦答案
Google Chrome 提供了一種在您實例化驅動程序時模擬移動設備的機制,請參閱完整文檔 這里.
Google Chrome provides a mechanism for emulating mobile devices when you instantiate the driver, see the full docs here.
例子:
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);
這篇關于如何在桌面瀏覽器上使用 webdriver mobile web的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!