如何在桌面浏览器上使用webdriver移动网络 [英] How to use webdriver mobile web on desktop browser

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

问题描述

我使用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来自手机浏览器。因为当我们在移动浏览器中打开时它是响应式web,所以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自动化完成。我的问题是如何使用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移动网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆