目录

store系列简介

相关方法

官方API

验证过程

命令详解


store系列简介

主要用于存储,将数据存储到变量中,以便调用;

相关方法

store
store attribute
store json
store text
store title
store value
store window handle
store xpath count

官方API

store

Save a target string as a variable for easy re-use.

arguments

  • text: The text to use.

  • variable name: The name of a variable without brackets.


store attribute

Gets the value of an element attribute. The value of the attribute may differ across browsers (this is the case for the "style" attribute, for example).

arguments

  • attribute locator: An element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar".

  • variable name: The name of a variable without brackets.


store json

undefined

arguments

  • json: A string representation of a JavaScript object.

  • variable name: The name of a variable without brackets.


store text

Gets the text of an element and stores it for later use. This works for any element that contains text.

arguments

  • locator: An element locator.

  • variable name: The name of a variable without brackets.


store title

Gets the title of the current page.

arguments

  • text: The text to use.

  • variable name: The name of a variable without brackets.


store value

Gets the value of element and stores it for later use. This works for any input type element.

arguments

  • locator: An element locator.

  • variable name: The name of a variable without brackets.


store window handle

Gets the handle of the current page.

arguments

  • window handle: A handle representing a specific page (tab, or window).

store xpath count

Gets the number of nodes that match the specified xpath (e.g. "//table" would give the number of tables).

arguments

  • xpath: The xpath expression to evaluate.

  • variable name: The name of a variable without brackets.

验证过程

测试页面代码store.html

<!DOCTYPE html>
<html><head><title>selenium 学习之 store系列 </title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
</style>
<script type="text/javascript"></script>
</head><h1>selenium test 之 store系列 </h1>
<div id="main"><input type="text" value="" id="test1" name="myinput" /><br/><span id="test2" style="color:red;width:200px">AKDJDJDJDJKL0</span><br/><br/><h3>store value</h3><span id="vv_1">this is span</span><br/><input type="text" id="vv_2" /><br/><input type="text" id="vv_3" value="1" /><br/><br/><br/>下拉框<select id='vv_4'><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option></select><br/><br/>交通工具复选:<input type="checkbox" id="vv_5" name="vehicle" value="Car"/>小车<br/><input type="checkbox" id="vv_5x" name="vehicle" value="posche"  checked/>保时捷<br/><input type="checkbox" id="vv_5xx" />三轮车<br/>单选颜色:<input type="radio" id="vv_7" name="colors"  value="red">红色<br><input type="radio" id="vv_8" name="colors" value="blue" checked>蓝色1<br><br></div>
</body>
</html>

selenium IDE脚本:

side文件代码

{"id": "b2a0115e-7483-440e-9949-01b82230bf97","version": "2.0","name": "store","url": "http://localhost:8080/","tests": [{"id": "92c31d47-a26b-4713-bbee-9fa7439e30f5","name": "store","commands": [{"id": "38d7d236-56a9-439a-a23c-a2abd1751d67","comment": "","command": "open","target": "/aa/store.html","targets": [],"value": ""}, {"id": "41b49190-7971-4820-90e8-26dfacd9df10","comment": "","command": "setWindowSize","target": "1187x870","targets": [],"value": ""}, {"id": "01b3f74e-d1b1-46a5-983c-b058b1e2fb77","comment": "","command": "//1、store","target": "","targets": [],"value": ""}, {"id": "27d430b0-a72a-466f-963e-89ff7f336e3c","comment": "","command": "store","target": "vartext","targets": [],"value": "amvar"}, {"id": "312b066f-ece8-4cfe-bb6a-5b3d2ae65ac3","comment": "","command": "type","target": "id=test1","targets": [["id=test1", "id"],["name=myinput", "name"],["css=#test1", "css:finder"],["xpath=//input[@id='test1']", "xpath:attributes"],["xpath=//div[@id='main']/input", "xpath:idRelative"],["xpath=//input", "xpath:position"]],"value": "${amvar}${amvar}"}, {"id": "7ee02f11-d4c2-4adc-97e8-5615049792a4","comment": "","command": "echo","target": "${amvar}${amvar}","targets": [],"value": ""}, {"id": "e3b8abbd-e543-4b5c-a950-cff1fd6a2fb9","comment": "","command": "//1、store attribute","target": "","targets": [],"value": ""}, {"id": "12e9085f-bb3c-40f5-857b-38435f6a5af7","comment": "","command": "storeAttribute","target": "id=test1@name","targets": [],"value": "attr_var"}, {"id": "ff4dd855-397f-4dab-b953-42e970fc4c48","comment": "","command": "echo","target": "${attr_var}","targets": [],"value": ""}, {"id": "62aaa898-d595-4eae-ae90-fd134886daae","comment": "","command": "echo","target": "${attr_var}","targets": [],"value": ""}, {"id": "140f06c9-945c-450a-9e86-93c1174011ca","comment": "","command": "storeAttribute","target": "id=test2@style","targets": [],"value": "attr_var"}, {"id": "6381e1b1-bfb0-495c-ac1e-e9fe27090bb8","comment": "","command": "echo","target": "${attr_var}","targets": [],"value": ""}, {"id": "68418d9a-5d9b-48f3-83de-221f9f267408","comment": "","command": "//2、store json","target": "","targets": [],"value": ""}, {"id": "27366728-f554-4995-b97e-ddb67108239e","comment": "","command": "storeJson","target": "{\"a\": [a,]}","targets": [],"value": "json_var"}, {"id": "e4556852-2782-4d89-bda4-8847a6d850b8","comment": "","command": "storeJson","target": "{\"a\": 1, \"b\": [1, 2, 3]}","targets": [],"value": "json_var"}, {"id": "6827e422-81a1-49ff-a0d2-b28a2cd967c0","comment": "","command": "echo","target": "${json_var}","targets": [],"value": ""}, {"id": "24e755b7-08b7-4aa1-8c48-be5a24dfc63e","comment": "","command": "echo","target": "${json_var.a}","targets": [],"value": ""}, {"id": "990a71e9-bb36-41e5-89ab-131e7002481b","comment": "","command": "echo","target": "${json_var.b}","targets": [],"value": ""}, {"id": "3d992e35-877c-4fb8-98a3-23d83bd80554","comment": "","command": "echo","target": "${json_var.b[0]}","targets": [],"value": ""}, {"id": "516a7d76-2661-4776-a54d-611fa9586099","comment": "","command": "echo","target": "${json_var.b[4]}","targets": [],"value": ""}, {"id": "f44df283-9de2-4645-878a-081f547de5e3","comment": "","command": "storeJson","target": "[1, 2, \"3\", {\"a\": 4}]","targets": [],"value": "json_var"}, {"id": "ac188f57-df23-4f1e-83cd-f3b828c9e038","comment": "","command": "echo","target": "${json_var}","targets": [],"value": ""}, {"id": "8ee484ce-f3ef-4c53-9bc9-a9c97aeec134","comment": "","command": "echo","target": "${json_var[3].a}","targets": [],"value": ""}, {"id": "245fdeb9-ec47-4a2c-93da-c4c06dc43ce3","comment": "","command": "//3、store text","target": "","targets": [],"value": ""}, {"id": "9e386d61-1ee0-4313-af49-6b30af374520","comment": "","command": "storeText","target": "xpath=//div","targets": [],"value": "text_var"}, {"id": "6d26d2b6-7a78-4bfd-be60-eda5aa2cc052","comment": "","command": "echo","target": "${text_var}","targets": [],"value": ""}, {"id": "68b833e8-e107-47a6-bafc-f8b19af63033","comment": "","command": "storeText","target": "id=vv_1","targets": [],"value": "text_var"}, {"id": "7e1f2ce5-aa87-4fde-b8fe-e268d7fb94dc","comment": "","command": "echo","target": "${text_var}","targets": [],"value": ""}, {"id": "d6519849-1747-4669-b227-b172a9fb830c","comment": "","command": "//3、store title","target": "","targets": [],"value": ""}, {"id": "ccaeb72c-2e35-48de-94b1-e90f1a9dc165","comment": "","command": "storeTitle","target": "AAA","targets": [],"value": "title_var"}, {"id": "d4a1c518-88b2-4e52-9446-a9052f78ce89","comment": "","command": "echo","target": "${title_var}","targets": [],"value": ""}, {"id": "7ecc4eb8-d0ba-4335-8f72-ac3dc168c34a","comment": "","command": "storeTitle","target": "","targets": [],"value": "title_var"}, {"id": "69854804-f20e-43b4-9ad4-7833126bfb77","comment": "","command": "echo","target": "${title_var}","targets": [],"value": ""}, {"id": "099d10af-f338-4f77-bc9c-d31f52f31a64","comment": "","command": "//4、store value","target": "","targets": [],"value": ""}, {"id": "0833504a-1c96-4133-8e59-8c0f5a1cb24b","comment": "","command": "//storeValue","target": "","targets": [],"value": ""}, {"id": "0f5f4d87-4790-411b-9c5e-2eee5a00db9d","comment": "span  fail","command": "//storeValue","target": "id=vv_1","targets": [],"value": "vv1"}, {"id": "d0d6be4d-7a27-4af0-a7fb-9c7808e52ea5","comment": "","command": "//echo","target": "${vv1}","targets": [],"value": ""}, {"id": "0363d790-74a8-484e-b402-ce32a34eed9b","comment": "","command": "open","target": "/aa/store.html","targets": [],"value": ""}, {"id": "9d931c89-0104-4db8-a75c-57870fb039a5","comment": "","command": "storeValue","target": "id=vv_2","targets": [["id=vv_3", "id"],["css=#vv_3", "css:finder"],["xpath=//input[@id='vv_3']", "xpath:attributes"],["xpath=//div[@id='main']/input[2]", "xpath:idRelative"],["xpath=//input[2]", "xpath:position"]],"value": "vv2"}, {"id": "645db441-8513-44f3-afc1-79917b31f05c","comment": "","command": "echo","target": "${vv2}","targets": [],"value": ""}, {"id": "c31d1ad7-4302-4c23-8185-71f6637b5088","comment": "","command": "type","target": "id=vv_2","targets": [],"value": "870320"}, {"id": "39075e77-a650-4bdc-b43d-a757d076ceec","comment": "","command": "storeValue","target": "id=vv_2","targets": [["id=vv_3", "id"],["css=#vv_3", "css:finder"],["xpath=//input[@id='vv_3']", "xpath:attributes"],["xpath=//div[@id='main']/input[2]", "xpath:idRelative"],["xpath=//input[2]", "xpath:position"]],"value": "vv2"}, {"id": "efb3b9c7-ae6c-44b7-af28-0ac662898614","comment": "","command": "echo","target": "${vv2}","targets": [],"value": ""}, {"id": "dece7758-4132-4e73-946f-5c7745c088f5","comment": "","command": "storeValue","target": "id=vv_3","targets": [["id=vv_3", "id"],["css=#vv_3", "css:finder"],["xpath=//input[@id='vv_3']", "xpath:attributes"],["xpath=//div[@id='main']/input[2]", "xpath:idRelative"],["xpath=//input[2]", "xpath:position"]],"value": "vv3"}, {"id": "5ac58c71-fbd9-46e1-96fd-f3a823f539c0","comment": "","command": "echo","target": "${vv3}","targets": [],"value": ""}, {"id": "9b544af1-c472-43a1-91fd-c28ada0f2f8b","comment": "","command": "type","target": "id=vv_4","targets": [],"value": "mercedes"}, {"id": "8f6750d1-fba0-4fef-82b1-c7b7c9a81e20","comment": "","command": "storeValue","target": "id=vv_4","targets": [["id=vv_4", "id"],["css=#vv_4", "css:finder"],["xpath=//select[@id='vv_4']", "xpath:attributes"],["xpath=//div[@id='main']/select", "xpath:idRelative"],["xpath=//select", "xpath:position"]],"value": "vv4"}, {"id": "c6179c5e-0363-4440-95da-61c406bb831b","comment": "","command": "echo","target": "${vv4}","targets": [],"value": ""}, {"id": "324d4e58-a351-4890-bfae-5a0fe9787c8a","comment": "","command": "storeValue","target": "id=vv_5","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "vv5"}, {"id": "81774e92-2ab6-4709-8f32-51e2c0f0056f","comment": "","command": "echo","target": "${vv5}","targets": [],"value": ""}, {"id": "d336c5a5-8a74-4016-bfec-16a975bb0806","comment": "","command": "storeValue","target": "name=vehicle","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "namevv5x"}, {"id": "bef35dc6-67a6-4d0b-82c9-8cd6d5a655be","comment": "","command": "echo","target": "${namevv5x}","targets": [],"value": ""}, {"id": "9b7ea4ed-910f-49c8-abd8-250496668e51","comment": "","command": "storeValue","target": "id=vv_5xx","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "vv5xx"}, {"id": "5e57ef5e-611d-4b5a-ac63-a4c6ed5cf0b4","comment": "","command": "echo","target": "${vv5xx}","targets": [],"value": ""}, {"id": "1c62d9a4-94a9-42b7-923d-c23e3fd9929b","comment": "","command": "storeValue","target": "id=vv_7","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "vv7"}, {"id": "5beac14e-685a-4bad-a592-ce16678634f1","comment": "","command": "echo","target": "${vv7}","targets": [],"value": ""}, {"id": "03b7c1ba-0f43-4042-aaa6-827d0aff7bac","comment": "","command": "storeValue","target": "id=vv_8","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "vv8"}, {"id": "6f845356-afd4-4afa-a8f1-d0e08c5005b9","comment": "","command": "echo","target": "${vv8}","targets": [],"value": ""}, {"id": "c777a216-c097-4836-aee0-6f499d74f340","comment": "","command": "storeValue","target": "name=colors","targets": [["id=vv_5", "id"],["name=vehicle", "name"],["css=#vv_5", "css:finder"],["xpath=//input[@id='vv_5']", "xpath:attributes"],["xpath=//div[@id='main']/input[3]", "xpath:idRelative"],["xpath=//input[3]", "xpath:position"]],"value": "namevv7"}, {"id": "99ea2268-eeca-477d-8398-1c3cd99f06f6","comment": "","command": "echo","target": "${namevv7}","targets": [],"value": ""}, {"id": "576b2f0d-9c57-48f4-9e6b-2b3d3cfae3bb","comment": "","command": "//6、store window handle","target": "","targets": [],"value": ""}, {"id": "fc22f28e-046a-46ac-a7b5-e05a2cebc9f0","comment": "","command": "storeWindowHandle","target": "www","targets": [],"value": ""}, {"id": "b9e978bb-910a-43ab-9bbd-04ab7511c626","comment": "","command": "echo","target": "${www}","targets": [],"value": ""}, {"id": "f08dfa63-4bb0-4fce-a306-39e3d5107658","comment": "","command": "//7、store xpath count","target": "","targets": [],"value": ""}, {"id": "a55f0a00-d44a-44f9-9a5d-2bc5fa806349","comment": "","command": "storeXpathCount","target": " xpath=//div/input","targets": [],"value": "xpath_var"}, {"id": "6f92b8ad-3105-45bb-89ac-1cb137b11841","comment": "","command": "echo","target": "${xpath_var}","targets": [],"value": ""}]}],"suites": [{"id": "698e677b-2eb9-499e-a5ff-ff5c8c827688","name": "Default Suite","persistSession": false,"parallel": false,"timeout": 300,"tests": ["92c31d47-a26b-4713-bbee-9fa7439e30f5"]}],"urls": ["http://localhost:8080/"],"plugins": []
}

命令详解

store
解析:存储一个字符串到变量里面以便复用。

store attribute
解析:获得指定元素的属性到变量中,获得的方式,在元素位置后面通过@符号指定属性。

store json
解析:存储json到变量中。
注意:
1、json不符合格式规范存储会失败;
2、json存储后读取的时候,可以直接通过json指定读取key或通过下标读取;
3、json键值对不要用单引号,单引号会报错,用双引号;

store text
解析:存储指定元素的内容到变量中。
注意:会存储指定元素包含的文本以及子节点的所有文本(非标签的内容);

store title
解析:获得单签界面的标题并存储。
注意:
1、这个方法的api没看到,两个参数,第一个是text,与方法的解析有出入,如果传递第一个参数,那么与store的用法是相同的;
2、如果不传递第一个参数,即传递空值或ide第一个参数留空,那么会将当前界面的title存储到变量中;(正常使用应该也是如此)
3、如果界面没有title标签,那么获得的标签是空白;

store value
解析:获得指定元素的值并存储到变量中,主要用于input类型的控件。
注意:
1、其他控件如span调用会出错;
2、只要input控件有value就直接获取,如果是input控件,但是没有value属性,输入项是空的,那么会返回undefined;
3、单选、复选框如果有value直接获取value属性值,如果没有,获得的值一直是on;

store window handle
解析:存储window窗口的句柄。
注意:
1、官网api给的参数没看懂,试验过程中带参验证不通过;
2、推测的用法只有一个参数,是输出参数,即变量名,见示例,是存储变量的名称;
3、句柄返回的一般是下标,存储的是windows的tab或window窗体的标记,一般用于控制窗口(切换展示、关闭、其他操作等);

store xpath count
解析:存储xpath下统计出来符合条件的元素数量。
注意:
1、xpath根据自己的定义进行统计;
2、此方法用的相对较少,主要可以统计符合xpath的元素数量;

Selenium学习(七) selenium IDE命令之 store系列详解相关推荐

  1. Selenium学习(十) selenium IDE命令之 verify系列详解

    目录 verify系列简介 相关方法 官方API 验证过程 命令详解 verify系列简介 Verify系列是验证,验证目标对象是否一致或不一致. 无论验证结果成功或失败,均继续执行. 相关方法 ve ...

  2. 【深度学习】轻量化CNN网络MobileNet系列详解

    深度学习100问 Author:louwill Machine Learning Lab MobileNet系列作为轻量级网络的代表,使得CNN轻量化和移动端的部署成为可能.MobileNet系列目前 ...

  3. Linux Bash命令关于程序调试详解

    转载:http://os.51cto.com/art/201006/207230.htm 参考:<Linux shell 脚本攻略>Page22-23 Linux bash程序在程序员的使 ...

  4. python定位相邻节点_Python selenium 父子、兄弟、相邻节点定位方式详解

    今天跟大家分享下selenium中根据父子.兄弟.相邻节点定位的方法,很多人在实际应用中会遇到想定位的节点无法直接定位,需要通过附近节点来相对定位的问题,但从父节点定位子节点容易,从子节点定位父节点. ...

  5. 转 虫师的selenium借助AutoIt识别上传(下载)详解

    selenium借助AutoIt识别上传(下载)详解 2014-12-27 11:26 by 虫师, 755 阅读, 1 评论, 收藏,  编辑 AutoIt目前最新是v3版本,这是一个使用类似BAS ...

  6. Ext.Net学习笔记22:Ext.Net Tree 用法详解

    上面的图片是一个简单的树,使用Ext.Net来创建这样的树结构非常简单,代码如下: <ext:TreePanel runat="server"><Root> ...

  7. Shell test命令(Shell [])详解,附带所有选项及说明

    test 是 Shell 内置命令,用来检测某个条件是否成立.test 通常和 if 语句一起使用,并且大部分 if 语句都依赖 test. test 命令有很多选项,可以进行数值.字符串和文件三个方 ...

  8. 第七章httpd.conf主配置文件的详解

    版本V1.0 时间2012-10-04 版权GPL 作者itnihao 邮箱 itnihao@qq.com 博客 http://itnihao.blog.51cto.com 如需重新发行,请注明以上信 ...

  9. linux ipset 流量,linux中ipset命令的使用方法详解

    linux中ipset命令的使用方法详解 发布时间:2020-10-25 17:07:19 来源:脚本之家 阅读:97 作者:lijiaocn 栏目:服务器 ipset介绍 iptables是在lin ...

最新文章

  1. 《高质量java程序设计》读书笔记之----异常处理(1)
  2. 『TensorFlow』专题汇总
  3. 无法嵌入互操作类型“……”,请改用适用的接口的解决方法
  4. EasyTrack项目管理软件的四大版本和相关组件介绍
  5. 名企进名校精选IT人 07年毕业生就业看好
  6. Spring AOP 实战运用
  7. ASP.NET Core自定义响应内容
  8. drools dmn_使用Drools的DMN运行时示例
  9. SpringCloud或SpringBoot+Mybatis-Plus利用mybatis插件实现数据操作记录及更新对比
  10. 一:Java+SpringBoot框架框架的安装和启用
  11. 事件管理决定一个网管软件的成功与失败
  12. delphi三方控件的安装方法
  13. java修改.class重新打包jar
  14. spring mvc路径匹配原则
  15. RAC安装之一 安装前准备
  16. 2021美团笔试题(第十套)个人解答
  17. adb install -r -d的含义
  18. 社工小组 计算机小组活动,小组工作活动计划1
  19. 大数据分析技术有哪些
  20. 金融衍生品PK:期权和权证俩兄弟

热门文章

  1. 04.声明式服务调用:Spring Cloud Feign(Greenwich.SR2)
  2. 获取各大电商平台、1688app上商品详情原数据API调用展示
  3. 与幼儿园小朋友一起过感恩节心得
  4. win7命令启动计算机管理,关于Win7中运行的命令
  5. 线程通信,生产者消费者问题案例,模拟来电提醒和接听电话
  6. 权威认证 | 云和恩墨zData Light存储管理软件获H3C兼容认证
  7. matlab创新开放性实验,《线性代数》实验课程大纲.doc
  8. Golang图片码+压缩伪装+远程调用组合拳
  9. 【Python数据分析】之数据合并的concat函数与merge函数
  10. python图像分割算法_用python实现随机森林图像分割