selenium 2 关于移动端wap网页的测试,3种解决思路。
来源:互联网 发布:java mail ssl 编辑:程序博客网 时间:2024/06/11 09:02
本文纯属虚构:
1.使用第三方浏览器模拟,本文拟用chrome。
chrome 支持 主流系统ios、Android的浏览器模拟。
如图
java 初始化driver//userAgent 可以通过上图UA栏获取,如:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53String userAgent = "user_agent_string";chromeOptions co = new ChromeOptions();co.addArguments("--user-agent=" + userAgent);DesiredCapabilities cap = DesiredCapabilities.chrome();cap.setCapability(ChromeOptions.CAPABILITY , co);WebDriver driver = new ChromeDriver(cap);
其他语言参考:http://simply-tutorial.com/blog/2014/07/10/selenium-webdriver-set-browsers-user-agent-and-proxy/2.使用selenium 的androiddriver,iphonedriver,
需要下载以Android为例,下载 androiddriver以及Android-server.apk,android模拟器(或使用真机) ,速度较慢1. Setup Android emulator a. Download the Android SDK http://developer.android.com/sdk/index.html Note that there is an emulator bug on Gingerbread((2.3.x) that might cause WebDriver to crash. My testing is on Ice Cream Sandwich (4.0.x)
b. Install Android SDK: http://developer.android.com/sdk/installing.html
c. Start Android SDK Manager (SDK Manager.exe) d. Select and install Package online e. Start AVD Manager.exe f. Create an emulator
2. Install the AndroidDriver APK by using platform-tools a. list divce name: adb devices b. download AndroidDriver APK: http://code.google.com/p/selenium/downloads/list c. install AndroidDriver APK: adb -s emulator-5554 -e install -r c:\android-server-2.21.0.apk d. start the Android WebDriver application adb -s emulator-5554 shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity e. setup the port forwarding in order to forward traffic from the host machine to the emulator adb -s emulator-5554 forward tcp:8080 tcp:8080
3. 编写测试脚本运行:import junit.framework.TestCase; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.android.AndroidDriver; public class OneTest extends TestCase { public void testGoogle() throws Exception { WebDriver driver = new AndroidDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }来自:http://blog.csdn.net/gxlujun/article/details/75205583.使用appium /或者robotium等,如果单单测试wap页,此方法不推荐。效率不高.有种高射炮打蚊子的意思。不在赘述,自行google
- selenium 2 关于移动端wap网页的测试,3种解决思路。
- 移动端 关于 键盘将input 框 顶上去的解决思路
- selenium常见错误的解决思路
- 关于网页设计的思路
- 一个网页适应多种不同屏幕的移动wap开发
- selenium+Python 实现简单的网页测试
- selenium+jenkins网页自动化测试的构建
- selenium+jenkins网页自动化测试的构建
- selenium+jenkins网页自动化测试的构建
- 两份关于 selenium/xpath 元素定位的极品 pdf,同样适用于移动测试
- 利用Selenium自动化测试android wap页
- Selenium+AdroidDriver测试android wap页
- 使用selenium测试网页
- 解决网页浏览故障的一般思路
- jenkins运行selenium时不显示浏览器的几种解决思路
- 关于浏览器端的网页性能测试
- 关于浏览器端的网页性能测试
- 关于selenium android下的浏览器测试
- 第一周项目三 时间类(2)增加多秒/分/时
- MySQL导出数据库结构出现Cannot load from mysql.proc错误的解决方法
- NavigationViewController
- httpclient支持https,http请求
- xxx应用在后台时,突然提示"很抱歉,xxx已停止运行"
- selenium 2 关于移动端wap网页的测试,3种解决思路。
- Unable to compile class for JSP 解决办法
- Android:设计之屏幕适配
- cocos: command not found
- xib自定义cell,返回cell高度
- 通过经纬度确定一定范围内哪些门店离客户最近,如1000米内有哪些最近的某某门店
- 常用网址入口
- drupal再nginx下开启rewrite简介链接
- 基于 Lucene 的8 个开源搜索引擎