Session

Create New Session

Java:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3");
desiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
desiredCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
desiredCapabilities.setCapability(MobileCapabilityType.APP, "/path/to/ios/app.zip"); URL url = new URL("http://127.0.0.1:4723/wd/hub"); IOSDriver driver = new IOSDriver(url, desiredCapabilities);
String sessionId = driver.getSessionId().toString();

Python:

desired_caps = desired_caps = {
'platformName': 'Android',
'platformVersion': '7.0',
'deviceName': 'Android Emulator',
'automationName': 'UiAutomator2',
'app': PATH('/path/to/app')
}
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

Description

The server should attempt to create a session that most closely matches the desired and required capabilities.

JSONWP Spec Required capabilities have higher priority than desired capabilities and must be set for the session to be created W3C Spec capabilities.alwaysMatch must be set for session to be created; capabilities.firstMatch must match at least one (the first one to match will be used)

End Session

Java:driver.quit();

Python:self.driver.quit()

Get Session Capabilities

Retrieve the capabilities of the specified session

Java:Map<String, Object> caps = driver.getSessionDetails();

Python:desired_caps = self.driver.desired_capabilities()

Go Back

Navigate backwards in the browser history, if possible (Web context only)

Java:driver.back();

Python:self.driver.back()

Take Screenshot

Take a screenshot of the current viewport/window/page

Java:File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

Python:screenshotBase64 = self.driver.get_screenshot_as_base64()

Get Page Source

Get the current application hierarchy XML (app) or page source (web)

Java:String pageSource = driver.getPageSource();

Python:source = self.driver.page_source

Set Timeouts

Configure the amount of time that a particular type of operation can execute for before they are aborted

Java:driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

Python:self.driver.set_page_load_timeout(5000)

Set Implicit Wait Timeout

Set the amount of time the driver should wait when searching for elements

Java:driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Python:self.driver.implicitly_wait(5000)

Set Script Timeout

Set the amount of time, in milliseconds, that asynchronous scripts executed by execute async are permitted to run before they are aborted (Web context only)

Java:driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);

Python:self.driver.set_script_timeout(5000)

Get Orientation

Get the current device/browser orientation

Java:ScreenOrientation orientation = driver.getOrientation();

Python:orientation = self.driver.orientation()

Set Orientation

Set the current device/browser orientation

Java:driver.rotate(ScreenOrientation.LANDSCAPE);

**

Python:**driver.orientation = "LANDSCAPE"

Get Geolocation

Get the current geo location

Java:Location location = driver.location(); // Must be a driver that implements LocationContext

Python:location = self.driver.location()

Set Geolocation

Set the current geo location

Java:driver.setLocation(new Location(49, 123, 10)); // Must be a driver that implements LocationContext

Python:self.driver.set_location(49, 123, 10)

Get available log types

Get the log for a given log type. Log buffer is reset after each request

Java:Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();

Python:log_types = driver.log_types();

Get Logs

Get the log for a given log type. Log buffer is reset after each request

Java:LogEntries logEntries = driver.manage().logs().get("driver");

Python:logs = driver.get_log('driver');

Update Device Settings

Update the current setting on the device

Java:driver.setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, Duration.ofSeconds(5));

Python:self.driver.update_settings({"sample": "value"}))

Retrieve Device Settings

Retrieve the current settings on the device

Java:Map<String, Object> settings = driver.getSettings();

Python:self.driver.get_settings

Appnium-API-Session的更多相关文章

  1. Web Api Session开启会话支持

        1.WebApi中默认是没有开启Session会话支持的.需要在Global中重写Init方法来指定会话需要支持的类型           //代码如下 public override voi ...

  2. 购物车Demo,前端使用AngularJS,后端使用ASP.NET Web API(2)--前端,以及前后端Session

    原文:购物车Demo,前端使用AngularJS,后端使用ASP.NET Web API(2)--前端,以及前后端Session chsakell分享了前端使用AngularJS,后端使用ASP.NE ...

  3. laravel 4.2 session

    laravel的session简要API Session的API还是比较简单的,大家看看中文文档也大概知道是怎么个意思.但是有那么几个还不太好理解. //session的永久保存(在不过期范围内) S ...

  4. laravel框架session使用教程

    laravel是一款php框架了,在使用laravel时会碰到session使用问题了,在使用过程中碰到一些问题与一些应用的例子. 用Laravel开发应用,把原有的代码copy过来,以前的代码ses ...

  5. Jetty开发指导:Jetty Websocket API

    Jetty WebSocket API使用 Jetty提供了功能更强的WebSocket API,使用一个公共的核心API供WebSockets的服务端和client使用. 他是一个基于WebSock ...

  6. 会话技术cookie和session详解

    什么是会话 会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 会话技术解决了什么问题 每个用户与服务器进行交互的过程中,各自会有一 ...

  7. 前端获得session信息方式对比,优化

    在开发中,页面 js 经常会遇到需要 当前登录用户信息(菜单权限,用户基本信息,配置信息) 的地方,一般情况我们可能对这些信息获取方式不是太在意,但是现在的前端通过webpack打包,即使做了代码分割 ...

  8. laravel中session的过期时间

    在项目开发的过程中,前后端分离 需要用session保存用户的登陆信息 这就涉及到session的有效期了 session又分为php中的session有效期和laravel中的session的有效期 ...

  9. electron api sendInputEvent 源码

    electron-master\electron-master\shell\browser\api\atom_api_web_contents.cc // Copyright (c) 2014 Git ...

  10. web 之 session

    Session? 在WEB开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占一个session对象(默认情况下).因此,在需要保存用户数据时,服务器程序可以 ...

随机推荐

  1. Ubutun 16.04添加操作命令审计

    1.启用/var/log/messages,监控系统命令 说明:由于需要把操作命令记录到/var/log/messages,但是ubuntu默认并没有开启日志写入到这个文件 tchua@ubuntu: ...

  2. 用redis实现分布式锁,秒杀案例(转)

    分布式锁的简单实现代码: 需要的jar包: jedis-2.9.0.jar. commons-pool2-2.4.2.jar import java.util.List; import java.ut ...

  3. linux cp 直接覆盖不提示信息 解决方法

    默认情况下,cp覆盖时,无论加什么参数 -f 之类的 还是提示是否覆盖. 原因是:服务器会默认增加别名 alias cp=’cp -i’,当你执行cp时,其实执行的是cp –i. [root@ltt0 ...

  4. 使用Crawler框架搭建自己的爬虫框架MyCrawler

    自己写一个爬虫框架的目的: 完美架构 在实际的数据采集编码过程中,发现代码比较乱,抓取数据,存储数据的代码混杂在一起,为了构建比较完美的数据采集框架 敏捷开发 将数据采集进行标准流程化,每个标准流程都 ...

  5. ES6和CommonJS的区别 以及 export和module.exports的区别

    ES6和CommonJS的区别 Javascript javascript是一种脚本编程语言,有自己独立的语法与语义,没有javascript,也就没有其他的那些概念了. ES6 JavaScript ...

  6. dp回文

    .dp回文子串 通常在dp数组中存放的是 从i到j是否是回文子串 1.动态规划 2.中心扩展法 #include<iostream> #include<algorithm> # ...

  7. BZOJ3033太鼓达人——哈密顿回路/欧拉回路

    题目描述 七夕祭上,Vani牵着cl的手,在明亮的灯光和欢乐的气氛中愉快地穿行.这时,在前面忽然出现了一台太鼓达人机台,而在机台前坐着的是刚刚被精英队伍成员XLk.Poet_shy和lydrainbo ...

  8. 线性回归中常见的一些统计学术语(RSE RSS TSS ESS MSE RMSE R2 Pearson's r)

    TSS: Total Sum of Squares(总离差平方和) --- 因变量的方差 RSS: Residual Sum of Squares (残差平方和) ---  由误差导致的真实值和估计值 ...

  9. Hackers' Crackdown UVA - 11825 (状压dp)

    给出n个电脑,每个电脑连着n个服务,然后每个电脑都连着m个邻电脑,如果当前的电脑某个服务被断开了,相邻的电脑的服务也会被断开,每个电脑都只能操作一次,问你最多可以让多少种服务被断开.一种服务被断开的条 ...

  10. BZOJ2655calc

    题目描述 一个序列a1,...,an是合法的,当且仅当:长度为给定的n.a1,...,an都是[1,A]中的整数.a1,...,an互不相等.一个序列的值定义为它里面所有数的乘积,即a1a2...an ...