Selenium AndroidDriver使用(一)

Selenium-AndroidDriver(python) (一) --- 环境配置及脚本运行 androiddriver环境配置 建模拟器 1. 下载模拟器并放到非中文路径下:http://developer.android.com/sdk/index.html 2.  解压并放到非中文路径下,如 D:\adt-bundle-windows-x86-20130917 3.  配置环境变量:我的电脑>属性>高级>环境变量>Path>变量值中加入adb.exe路径,如:..\and 阅读详情


参考:http://code.google.com/p/selenium/wiki/AndroidDriver


在http://code.google.com/p/selenium/downloads/list或http://seleniumhq.org/download/

下载Selenium IDE//用于在FireFox上录制Selenium脚本(html),并且可以将Selenium脚本(html)Export为JUnit 4 /WebDriver或其它语言的代码。

下载Test Suite Batch Converter//用于扩展Selenium IDE的Export功能。也是FireFox的plug

下载selenium-server-standalone-2.25.0.jar//JUnit工程需要的libs。用于向WebDriver发送命令。

下载android-server-2.21.0.apk//安装在android手机上,用于接收、处理selenium客户端传来的各种命令。


打开FireFox,通过Selenium IDE录制测试脚本,保存为DemoDroid.html,并运行一下。OK。

然后在Selenium IDE->File->Batch convert test cases->Java/ JUnit 4/ WebDriver,保存为DemoDroid.java。

大概是这样的:

package com.atest;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class BaiduKitty {
	private WebDriver driver;
	private String baseUrl;
	private StringBuffer verificationErrors = new StringBuffer();
	@Before
	public void setUp() throws Exception {
		driver = new FirefoxDriver();
		baseUrl = "http://www.baidu.com/";
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
	}

	@Test
	public void testBaiduKitty() throws Exception {
		// open | /index.html | 
		driver.get(baseUrl + "/index.html");
		// type | id=kw | Hello kitty
		driver.findElement(By.id("kw")).clear();
		driver.findElement(By.id("kw")).sendKeys("Hello kitty");
		// click | id=su | 
		driver.findElement(By.id("su")).click();
		// assertText | css=a > em | hello kitty
		assertEquals("hello kitty", driver.findElement(By.cssSelector("a > em")).getText());
	}

	@After
	public void tearDown() throws Exception {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}

	private boolean isElementPresent(By by) {
		try {
			driver.findElement(by);
			return true;
		} catch (NoSuchElementException e) {
			return false;
		}
	}
}




新建一个java工程SeleniumDemo。导入libs(selenium-server-standalone-2.25.0.jar)。将DemoDroid.java 拷进src里。


安装android-server-2.21.0.apk到手机上(2.3.x以上)。并运行。

在电脑上cmd。

>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
0163D4701901D01E        device

>adb -s 0163D4701901D01E forward tcp:8080 tcp:8080


DemoDroid.java上Run as JUnit Test

 OK  OK  OK


ps:

如果是FireFox  for Win,

System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla Firefox/firefox.exe");
driver = new FirefoxDriver();


如果是Chrome for Win,

下载ChromeDriver

System.setProperty("webdriver.chrome.driver", "E:/write/auto_test/chromedriver.exe");
driver = new ChromeDriver();



s



s

蓝桥杯STM32G431RBT6学习——GPIO 阅读详情

相关推荐

ADI官方例程HDL和No-OS生成Vivado工程

这一步是选择下载源,一般都是选择国内镜像,因为国外的源太慢了,这里选择阿里的镜像,如果没有这个选项可以在下面的User URL里添加就行,选择好源后然后点击下一步。下一步会从你选择的源上下载软件包目录,如果提示Unable to get setup from https://xxxxxx/,返回上一步,选择别的源,例如第二个163网易的源。然后就是你想要安装在哪了,下面的选项好像会决定环境变量存放在哪,不过一般都是个人电脑选择第一个默认的就行,然后点下一步。下好之后双击打开,就是这个界面了,直接点下一步。

代码匠的博客 3832

简单介绍一下Appium以及如何利用Appium使Selenium运行在Android平台上

Appium是一个开源自动化测试框架,可以在iOS和Android平台上使用Selenium WebDriver进行测试。 要在Android平台上使用Selenium运行Appium,需要安装Java JDK、Android SDK和Appium。然后,需要在Appium中配置好Android设备和Selenium驱动。最后,可以使用Appium提供的API来操作Android设备上的应用程序,...

weixin_42594419的博客 883

实战指南:从零开始用YOLOv8训练VisDrone无人机检测模型

本文提供了一份详细的实战指南,手把手教你从零开始使用YOLOv8训练一个无人机检测模型。内容涵盖VisDrone数据集下载与格式转换、YAML配置文件编写、模型训练与评估,以及最终的推理部署,旨在帮助开发者快速掌握无人机视角下的目标检测技术。

salt的博客 686

Selenium 各个浏览器以及Android设备驱动方法

SeleniumTest https://github.com/WeikiForNtt/SeleniumTest.git 这几天在做Selenium的测试,各个浏览器都做了下调查,共享一下所得 (1),Selenium具体是个什么东西,自己去百度,官网http://docs.seleniumhq.org/,如果打不开,要开VPN访问。 (2),Selenium对Web浏览器驱动 (...

weixin_30824479的博客 300

微信自动化必备软件:inspect(获取微信界面元素)

SaveButton10015.2:1 ✅(合格)Passed ✅说明这个控件完全符合无障碍标准。

Ven%的博客 1382

告别手动画图!用Cadence SKILL写一个参数化电感PCell(附完整代码)

本文详细介绍了如何使用Cadence SKILL语言开发参数化电感PCell,实现电感版图的自动化生成。通过动态调整线宽、圈数等几何参数,自动创建端口并进行工艺规则校验,大幅提升高频电路设计效率。附完整代码示例,帮助工程师快速掌握PCell开发技巧。

weixin_30684743的博客 368

Selenium+AdroidDriver测试android wap页

分类 针对智能手机端的应用的自动化测试,目前主要分两类: 一是基于APP的apk自动化测试, 二是浏览器的wap页测试。 目前做的较多的是第一种情况,应用的自动化测试框架也较多,如NativeDriver、Robotium、calabash等;而第二种情况的自动化测试框架就较少了,目前较常用的为Selenium。 用途 测试手机浏览器上的网站 AndroidDrive

我的E家 9875

智能车竞赛走马观碑组:赛道元素与目标板识别策略解析

本文深入解析了智能车竞赛走马观碑组别的核心挑战与策略。重点探讨了如何应对PVC赛道的光照、磨损及无边界线等复杂环境,并详细阐述了基于红色引导区的目标板高效识别流程。通过平衡轻量化模型选择、实时决策与精准控制,实现赛道元素适应性与目标板识别策略的优化,为参赛者提供了一套完整的系统集成与实战调参思路。

x8y9z0的博客 460

利用Selenium自动化测试android wap页

针对智能手机端的应用的自动化测试,目前主要分两类:一是基于APP的apk自动化测试,二是浏览器的wap页测试。目前做的较多的是第一种情况,应用的自动化测试框架也较多,如NativeDriver、Robotium、calabash等;而第二种情况的自动化测试框架就较少了,目前较常用的为Selenium。 而利用Selenium的测试框架有Selenium+Junit、Selenium+te

u010675455的专栏 1987

Remote ID的调制解调FPGA实现

Remote ID源于航空安全需求,例如在无人机密集区域实现设备跟踪和防碰撞。它类似于航空领域的ADS-B系统,但针对低空飞行器。Remote ID系统通常工作在特定频段(如2.4 GHz或5.8 GHz),通过无线链路广播数据包,包含设备ID、经纬度、高度和速度等信息。调制解调过程确保这些数据在噪声环境中可靠传输。例如,标准如ASTM F3411定义了Remote ID的协议框架,其中调制解调是关键物理层组件。

yulongfenghu的博客 1506

Simulink仿真模块-Signal Generator

Signal Generator:生成各种波形 所在的位置库为:Simulink / Sources 模型为: 说明 Signal Generator模块可以产生四种不同波形: 正弦波 方波 锯齿波 随机 可以使用 hertz 或 rad/sec 为单位表示信号参数。双击模型可以选择需要生成的波形,如图所示: 使用默认参数值,可以获得下列波形之一: 波形 波形输出 正弦波 ...

jk_101的博客 2655

android selenium 视频,Selenium 与 Android自动化测试

Android WebDriverhttp://code.google.com/p/selenium/wiki/AndroidDriverSelenium官方支持的Android Driver支持模拟器和真机支持的平台:The current apk will only work with Gingerbread (2.3.x), Honeycomb (3.x), Ice Cream Sandwi...

weixin_39661881的博客 191

微信小程序 - 实现人脸识别对比+人脸相似度数据,用户从相册选择或拍照上传两张图片进行人脸对比得到人脸相似度及判断是否是同一个人,微信小程序检测人脸相似度(免费纯前端方案+调用第三方API接口方案)

微信小程序实现人脸识别对比,微信小程序人脸对比 人脸对比识别 人脸对比相似度,实现获取手机摄像头权限,调用相机拍照实现人脸识别相似度对比,小程序人脸相似度对比,快速识别两张照片的相似程度(用百分比)图片相似度对比在线测试,图片相似度对比,微信小程序人脸相似度对比分析,计算两张人脸的相似度,从而判断是否同一个人,并给出相似度评分。小程序如何实现人脸相似度比对,小程序纯前端怎么对比两张图片的相似度,计算两幅图像的相似度,图像相似度对比方法,调用百度AI的人脸识别,微信小程序中实现人脸识别认证,实现人脸检测、人脸

🏆 前端领域优质创作者 4863

appium遇到问题总结(不断更新)

问题1 执行脚本 报错: java.lang.NoSuchMethodError: org.openqa.selenium.remote.ErrorHandler.<init>(Lorg/openqa/selenium/remote/ErrorCodes;Z)V at io.appium.java_client.AppiumDriver.<clinit>(A...

weixin_30892889的博客 376

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

如何用Selenium的AndroidDriver在Andrioid模拟器上进行自动化测试

如何用Selenium的AndroidDriver在Andrioid模拟器上进行自动化测试 分类: QA and Testing Mobile 2012-05-02 17:0424人阅读评论(0) 收藏 举报 How to run automation on Androidemulator 1. SetupAndroid emulator   a. Download the A

hanqionglaaa的专栏 3930

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

我的第一个appium ——androidDriver

package com.example.test;import java.io.File; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit;import org.junit.After; import org.junit.Before; import org.junit.Test; im

Action 7352

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Selenium-AndroidDriver(python) (八) --- 无法输入中文

环境: Selenium +AndroidDriver +python android-server-2.21.0.apk driver.find_element_by_name("kew").send_keys(u"半身裙") #输入半身裙 无法输入中文、Selenium自身的一个bug,请查看: http://code.google.com/p/selenium/issu

水滴石穿 1612

Selenium_AndroidDriver

Introduction Android WebDriver allows to run automated end-to-end tests that ensure your site works correctly when viewed from the Android browser. Android WebDriver supports all core WebDriver API

jiguanghoverli的专栏 4196

区分:AndroidDriver, iOSDriver, AppiumDriver and Remote WebDriver

区分:AndroidDriver, iOSDriver, AppiumDriver and Remote WebDriver 原文地址:https://discuss.appium.io/t/what-is-the-use-or-difference-between-androiddriver-iosdriver-appiumdriver-and-remote-webdriver/8750 R...

weixin_30415113的博客 444

AndroidDriver测试真机、虚拟机注意事项

[list] [*]Selenium地址:[url]http://code.google.com/p/selenium/[/url] [*]AndroidDriver地址:[url]http://code.google.com/p/selenium/wiki/AndroidDriver[/url] [/list] 1、断开、连接设备 [code="shell"] adb kill-se...

EmeraldSword的专栏 256

AndroidDriver原理初步--Android自动化测试学习历程

主要讲解内容及笔记: 一、AndroidDriver核心原理 对上图的解析: PC端的端口通过adb,将android版的Remote Server的apk push到手机上,然后跟手机端的Remote Server进行通信,手机端的Remote Server与浏览器进行通信,通过WebDriver注入js脚本到浏览器,完成想要完成的功能 基于控件的所有的自动化框架都调用了Ins...

weixin_30294021的博客 100

java appium selenium,使用Selenium+appium进行App测试

package appTest;import io.appium.java_client.AppiumDriver;import io.appium.java_client.android.AndroidDriver;import java.io.File;import java.net.URL;import java.util.List;import org.junit.After;import...

weixin_35644453的博客 548

什么是 Selenium 和 WebDriver?

Selenium是一个浏览器自动化操作框架。selenium主要由三种工具组成。 1.第一个工具——SeleniumIDE,是Firefox的扩展插件,支持用户录制和回访测试。录制/回访模式存在局限性,对许多用户来说并不适合。 2.因此第二个工具——Selenium WebDriver提供了各种语言环境的API来支持更多控制权和编写符合标准软件开发实践的应用程序。 3.最后一个工具——Sel...

yx_ming的博客 1万+
上一篇: android 分辨率适配与dip(dp)的使用
下一篇: RVM中文使用指南
andych008
博客等级 码龄19年 23粉丝 90原创
评论 7
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值