如何在桌面浏览器上使用 webdriver mobile web

How to use webdriver mobile web on desktop browser(如何在桌面浏览器上使用 webdriver mobile web)

本文介绍了如何在桌面浏览器上使用 webdriver mobile web的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在桌面浏览器上使用 webdriver mobile web

基础教程推荐