目录
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=