appium(13)- server config
//本文讲解:启动server时,如何配置capabilities 和 flag。可以将不同client端需要的通用的capabilities都放到server端配置。
Requirements
Installed Node.js 0.12 or greater.
At least an appium server instance installed via npm.
The basic principle.
It works the similar way as common ChromeDriver, InternetExplorerDriver of Selenium project or PhantomJSDriver. They use subclasses of the DriverService.
Which capabilities this feature provides
This feature providese abilities and options of the starting of a local Appium node server. End users still able to open apps as usual
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 120);
driver = new AndroidDriver<>(new URL("remoteOrLocalAddress"), capabilities);
when the server is launched locally\remotely. Also user is free to launch a local Appium node server and open their app for the further testing the following way:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 120);
driver = new AndroidDriver<>(capabilities);
How to prepare the local service before the starting
If there is no specific parameters then
import io.appium.java_client.service.local.AppiumDriverLocalService;
... AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
service.start();
...
service.stop();
FYI
There are possible problems related to local environment which could break this:
AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
It is more usual for UNIX/LINUX-like OS's. Also there are situations when should be used an another Node.JS instance, e.g. the instance which is installed in the directory that differs from one defined at the PATH environmental variable. The same may be true for Appium node server (it is related to appium.js file (v <= 1.4.16) and main.js (v >= 1.5.0)).
At this case user is able to set up values of the NODE_BINARY_PATH (The environmental variable used to define the path to executable NodeJS file (node.exe for WIN and node for Linux/MacOS X)) and the APPIUM_BINARY_PATH (The environmental variable used to define the path to executable appium.js (1.4.x and lower) or main.js (1.5.x and higher)) environmental variables/system properties. Also it is possible to define these values programmatically:
//appium.node.js.exec.path
System.setProperty(AppiumServiceBuilder.NODE_PATH ,
"the path to the desired node.js executable"); System.setProperty(AppiumServiceBuilder.APPIUM_PATH ,
"the path to the desired appium.js or main.js"); AppiumDriverLocalService service = AppiumDriverLocalService.buildDefaultService();
If there should be non default parameters specified then
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
... AppiumDriverLocalService service = AppiumDriverLocalService.
buildService(new AppiumServiceBuilder().
withArgument(GeneralServerFlag.TEMP_DIRECTORY,
"The_path_to_the_temporary_directory"));
or
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
... AppiumDriverLocalService service = new AppiumServiceBuilder().
withArgument(GeneralServerFlag.TEMP_DIRECTORY,
"The_path_to_the_temporary_directory").build();
Lists of available server side flags are here:
- io.appium.java_client.service.local.flags.GeneralServerFlag;
- io.appium.java_client.service.local.flags.AndroidServerFlag;
- io.appium.java_client.service.local.flags.IOSServerFlag
Which parameters also can be defined
- If it is necessary to define some specific port or any free port
new AppiumServiceBuilder().usingPort(4000);
or
new AppiumServiceBuilder().usingAnyFreePort();
- If it is necessary to use another IP address
new AppiumServiceBuilder().withIPAddress("127.0.0.1");
- If it is necessary to define output log file
import java.io.File;
... new AppiumServiceBuilder().withLogFile(logFile);
- If it is necessary to define another Node.js executable file
import java.io.File; ... new AppiumServiceBuilder().usingDriverExecutable(nodeJSExecutable);
- If it is necessary to define another appium.js/main.js file
import java.io.File; ...
//appiumJS is the full or relative path to
//the appium.js (v<=1.4.16) or maim.js (v>=1.5.0)
new AppiumServiceBuilder().withAppiumJS(new File(appiumJS));
- It is possible to define server capabilities (node server v >= 1.5.0)
DesiredCapabilities serverCapabilities = new DesiredCapabilities();
...//the capability filling AppiumServiceBuilder builder = new AppiumServiceBuilder().
withCapabilities(serverCapabilities);
AppiumDriverLocalService service = builder.build();
service.start();
...
service.stop();
Capabilities which are used by a builder can be completed/orerriden any similar way://server端与client端配合,配置capability的例子
DesiredCapabilities serverCapabilities = new DesiredCapabilities();
serverCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
serverCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
serverCapabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
serverCapabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);
serverCapabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
serverCapabilities.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE,
chrome.getAbsolutePath()); //this capability set can be used for all cases AppiumServiceBuilder builder = new AppiumServiceBuilder().
withCapabilities(serverCapabilities);
AppiumDriverLocalService service = builder.build(); DesiredCapabilities clientCapabilities = new DesiredCapabilities();
clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,
"io.appium.android.apis");
clientCapabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,
".view.WebView1");
then
AndroidDriver<MobileElement> driver =
new AndroidDriver<>(service, clientCapabilities);
or
AndroidDriver<MobileElement> driver =
new AndroidDriver<>(builder, clientCapabilities);
or
service.start();
AndroidDriver<MobileElement> driver =
new AndroidDriver<>(service.getUrl(), clientCapabilities);
How to create an AppiumDriver instance
Many constructors of AndroidDriver/IOSDriver use AppiumDriverLocalService or AppiumServiceBuilder as parameters. The list of constructors is below.
public AndroidDriver(URL remoteAddress,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(URL remoteAddress,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(AppiumDriverLocalService service,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(AppiumDriverLocalService service,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(AppiumServiceBuilder builder,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(AppiumServiceBuilder builder,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public AndroidDriver(org.openqa.selenium.Capabilities desiredCapabilities)
public IOSDriver(URL remoteAddress,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(URL remoteAddress,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(AppiumDriverLocalService service,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(AppiumDriverLocalService service,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(AppiumServiceBuilder builder,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(AppiumServiceBuilder builder,
org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory,
org.openqa.selenium.Capabilities desiredCapabilities) public IOSDriver(org.openqa.selenium.Capabilities desiredCapabilities)
An instance of AppiumDriverLocalService which has passed through constructors will be stopped when
driver.quit();
If it is necessary to keep the service alive during a long time then something like that is available
service.start(); .... new IOSDriver<MobileElement>(service.getUrl(), capabilities)
appium(13)- server config的更多相关文章
- Apache报错信息之Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config
今天配置开启Apache虚拟主机时, 然后日志报错提示: Invalid command 'Order', perhaps misspelled or defined by a module not ...
- 玩转Spring Cloud之配置中心(config server &config client)
本文内容导航: 一.搭建配置服务中心(config server) 1.1.git方式 1.2.svn方式 1.3.本地文件方式 1.4.解决配置中包含中文内容返回乱码问题 二.搭建配置消费客户端( ...
- appium for iOS config
appium-doctor: Running iOS Checks ✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer ...
- openSuSE DNS SERVER CONFIG
system:openSuSE 12.3(much better and frendly than the 12.1 in network config)1,network config,attent ...
- oracle server config
安装oracle数据库软件 database/runInstaller; ##执行该程序开始安装 创建数据库 在oracle用户的图形界面oracle用户中 新开启一个终端,直接输入命令dbca会弹出 ...
- ubuntu tftp server config
1.安装tftp-server sudo apt-get install tftpd-hpa sudo apt-get install tftp-hpa(如果不需要客户端可以不安装) tftp-hpa ...
- ubuntu nfs server config
(1)#sudo apt-get install nfs-kernel-server 打开/etc/exports文件,在末尾加入: /home/hyq *(rw,sync,no_root_squas ...
- appium server日志分析
文章出处http://blog.csdn.net/yan1234abcd/article/details/60765295 每次运行测试,可以从Appium Server控制台看到有特别多的日志输出, ...
- Appium Server源码分析之作为Bootstrap客户端
Appium Server拥有两个主要的功能: 它是个http服务器,它专门接收从客户端通过基于http的REST协议发送过来的命令 他是bootstrap客户端:它接收到客户端的命令后,需要想办法把 ...
随机推荐
- 焦作F Modular Production Line 费用流
题目链接 题解:这道题比赛的时候,学弟说是网络流,当时看N这么大,觉得网络流没法做,实际本题通过巧妙的建图,然后离散化. 先说下建图方式,首先每个覆盖区域,只有左右端点,如果我们只用左右端点的话,最多 ...
- 微信小程序 赋值问题
通常我们在页面跳转传递过来的参数要用到页面渲染时或是请求接口回来的数据要用到页面渲染时 对page的data赋值可不能用简单的变量赋值,要用微信小微信专有的this.setData方法 Page({ ...
- [原创][SW]TortoiseSVN创建本地版本控制
1. 简介 TortoiseSVN是一个Windows平台下的Subversion用户端软件,以Windows shell extension的方式写成.它是自由软件,以GNU通用公共许可证发布.(f ...
- HTTP基础认证Basic Authentication
HTTP基础认证Basic Authentication Basic Authentication是一种HTTP访问控制方式,用于限制对网站资源的访问.这种方式不需要Cookie和Session,只需 ...
- 断路器Hystrix与Turbine集群监控-Spring Cloud学习第三天(非原创)
文章大纲 一.Hystrix基础介绍二.断路器Hystrix简单使用三.自定义Hystrix请求命令四.Hystrix的服务降级与异常处理五.Hystrix的请求缓存与请求合并六.Hystrix仪表盘 ...
- java -agent与Javassist
javassist api https://blog.csdn.net/u011425751/article/details/51917895 晚些时候再补充一些使用注意事项.
- javascript --- 多重继承
多重继承就是指,一个子对象中有不止一个父对象的继承模式. 想要实现她,还是非常简单的,而我们只需要延续属性拷贝的继承思路依次扩展对象即可,而对参数中所继承的对象没有限制. function multi ...
- ios 使用 resignFirstResponder 无法hide键盘
- (BOOL)disablesAutomaticKeyboardDismissal { return NO;}
- Android开发者选项——Gpu呈现模式分析
对于Android用户来说,无论你用的什么品牌的手机,在开发者选项中都能发现“玄学曲线”的开关,之所以称其为玄学曲线,还是因为它被很多网友用于测试一个说不清道不明的东西——流畅度.到底多流畅才叫流畅, ...
- Zen of Python(Python的19条哲学)
The Zen of Python Beautiful is better than ugly. Explicit is better than implicit. Simple is better ...