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客户端:它接收到客户端的命令后,需要想办法把 ...
随机推荐
- LeetCode OJ--Regular Expression Matching
http://oj.leetcode.com/problems/regular-expression-matching/ 问题给想复杂了,只有p中可以含有. *,s中的字符都是确定的.想了好久,最终还 ...
- 在IOS11中position:fixed弹出框中的input出现光标错位的问题
问题出现的背景: 在IOS11中position:fixed弹出框中的input出现光标错位的问题 解决方案 一.设计交互方面最好不要让弹窗中出现input输入框: 二.前端处理此兼容性的方案思路: ...
- for 、foreach 、iterator 三种遍历方式的比较
习惯用法 for.foreach循环.iterator迭代器都是我们常用的一种遍历方式,你可以用它来遍历任何东西:包括数组.集合等 for 惯用法: List<String> list = ...
- HDU4126Genghis Khan the Conqueror(最小生成树+并查集)
Genghis Khan the Conqueror Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 327680/327680 K ...
- go mysql dsn
https://github.com/go-sql-driver/mysql#dsn-data-source-name DSN (Data Source Name) The Data Source N ...
- 如何获得(读取)web.xml配置文件的參数
參考代码例如以下: com.atguigu.struts2.app.converters.DateConverter.java public DateFormat getDateFormat(){ i ...
- VC++的project文件
VC++的project文件说明: *.dsp:是VC++的项目文件,文本格式. *.dsw:是工作区文件,它能够指向一个或多个.dsp文件. *.clw:是 ClassWizard信息文件,实际上是 ...
- surface 通过U盘 镜像恢复系统
1. 在恢复之前首先要解锁bitlocker(如果你的surface没有加锁就不需要这个步骤) 在另一台电脑上登录bitlocker锁绑定的微软账号,查询密钥,在需要的地方输入这个密钥(不经过这个操作 ...
- caffe2--Install
Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...
- shiro框架的使用
1.配置二级缓存 <ehcache updateCheck="false" name="shiroCache"> <defaultCache ...