Javascript selenium IDE正在尝试获取利润下限值
我正在尝试获取页面上某个元素的底部边距的值。该页面有一个选择框,允许访问者调整元素的底部边距。我想创建一个脚本来更改值,然后检查底部边距是否已更改。我对height参数做了类似的操作,但是有一个特定的断言。如何访问底部边距 我尝试了Javascript selenium IDE正在尝试获取利润下限值,javascript,testing,selenium,selenium-ide,Javascript,Testing,Selenium,Selenium Ide,我正在尝试获取页面上某个元素的底部边距的值。该页面有一个选择框,允许访问者调整元素的底部边距。我想创建一个脚本来更改值,然后检查底部边距是否已更改。我对height参数做了类似的操作,但是有一个特定的断言。如何访问底部边距 我尝试了assertAttributeelementid@style 但这只是给出了包含其他值的整个stlye 我在下面加入了我的身高脚本,虽然它对我没有多大帮助 <tr> <td>select</td> <td>
assertAttributeelementid@style
但这只是给出了包含其他值的整个stlye
我在下面加入了我的身高脚本,虽然它对我没有多大帮助
<tr>
<td>select</td>
<td>headerHeightSet</td>
<td>label=100</td>
</tr>
<tr>
<td>storeSelectedValue</td>
<td>headerHeightSet</td>
<td>topMarginValue</td>
</tr>
<tr>
<td>assertElementHeight</td>
<td>wemakeSheetHeaderJpg</td>
<td>${topMarginValue}</td>
</tr>
选择
头重脚轻
标签=100
存储选定值
头重脚轻
托普马金瓦卢
资产负债表
wemakeSheetHeaderJpg
${topMarginValue}
是的,根据我的发现,“storeAttribute”命令工作不好。我找到了几种不同的方法,但我认为使用用户扩展是最好的方法
HTML:
<html>
<head>
<script src="jquery-1.6.2.js"></script>
<style type="text/css">
body
{
margin:0px 0px 0px 0px;
}
.customDiv
{
border-style:solid;
border-color: green;
margin: 5px 50px 10px 0px; /* top bottom right left */
margin-color: black;
background-color: red;
padding: 50px 50px 50px 50px;
}
</style>
<script>
$(document).ready(function() {
jQuery("#BottomMarginSelect").change(function() {
jQuery("#CustomDiv").css("margin-bottom",jQuery("#BottomMarginSelect").val());
//alert(jQuery("#CustomDiv").css("margin-bottom"));
});
});
</script>
</head>
<body>
<div id="CustomDiv" class="customDiv">
text in div
</div>--- bottom margin of div ends here (100px below green div border); margin is always transparent ----
<br />
<br />
<b>Select the bottom margin of the div:<b><br />
<select id="BottomMarginSelect">
<option value="10px">10px</option>
<option value="20px">20px</option>
<option value="30px">30px</option>
</select>
</body>
</html>
Selenium.prototype.doStoreStyleAttribute = function(locator) {
var val = selenium.browserbot.getCurrentWindow().document.getElementById(locator).style.marginBottom;
this.doStore(val,"var_style_attribute_from_custom_command");
};
<tr>
<td>select</td>
<td>id=BottomMarginSelect</td>
<td>label=10px</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>id=BottomMarginSelect</td>
<td>var_BottomMarginSelect_select_option_selected_text</td>
</tr>
<tr>
<td>echo</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
<td></td>
</tr>
<tr>
<td>storeStyleAttribute</td>
<td>CustomDiv</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_custom_command}</td>
<td></td>
</tr>
<tr>
<td>assertExpression</td>
<td>${var_style_attribute_from_custom_command}</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@id='CustomDiv']/@style</td>
<td>var_style_attribute_from_id</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_id}</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@class='customDiv']/@style</td>
<td>var_style_attribute_from_class</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_class}</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>CustomDiv@style</td>
<td>var_style_attribute_from_storeAttribute</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_storeAttribute}</td>
<td></td>
</tr>
在Selenium IDE中设置用户扩展名文件:
<html>
<head>
<script src="jquery-1.6.2.js"></script>
<style type="text/css">
body
{
margin:0px 0px 0px 0px;
}
.customDiv
{
border-style:solid;
border-color: green;
margin: 5px 50px 10px 0px; /* top bottom right left */
margin-color: black;
background-color: red;
padding: 50px 50px 50px 50px;
}
</style>
<script>
$(document).ready(function() {
jQuery("#BottomMarginSelect").change(function() {
jQuery("#CustomDiv").css("margin-bottom",jQuery("#BottomMarginSelect").val());
//alert(jQuery("#CustomDiv").css("margin-bottom"));
});
});
</script>
</head>
<body>
<div id="CustomDiv" class="customDiv">
text in div
</div>--- bottom margin of div ends here (100px below green div border); margin is always transparent ----
<br />
<br />
<b>Select the bottom margin of the div:<b><br />
<select id="BottomMarginSelect">
<option value="10px">10px</option>
<option value="20px">20px</option>
<option value="30px">30px</option>
</select>
</body>
</html>
Selenium.prototype.doStoreStyleAttribute = function(locator) {
var val = selenium.browserbot.getCurrentWindow().document.getElementById(locator).style.marginBottom;
this.doStore(val,"var_style_attribute_from_custom_command");
};
<tr>
<td>select</td>
<td>id=BottomMarginSelect</td>
<td>label=10px</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>id=BottomMarginSelect</td>
<td>var_BottomMarginSelect_select_option_selected_text</td>
</tr>
<tr>
<td>echo</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
<td></td>
</tr>
<tr>
<td>storeStyleAttribute</td>
<td>CustomDiv</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_custom_command}</td>
<td></td>
</tr>
<tr>
<td>assertExpression</td>
<td>${var_style_attribute_from_custom_command}</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@id='CustomDiv']/@style</td>
<td>var_style_attribute_from_id</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_id}</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@class='customDiv']/@style</td>
<td>var_style_attribute_from_class</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_class}</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>CustomDiv@style</td>
<td>var_style_attribute_from_storeAttribute</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_storeAttribute}</td>
<td></td>
</tr>
选项>选项>
Selenium命令:
<html>
<head>
<script src="jquery-1.6.2.js"></script>
<style type="text/css">
body
{
margin:0px 0px 0px 0px;
}
.customDiv
{
border-style:solid;
border-color: green;
margin: 5px 50px 10px 0px; /* top bottom right left */
margin-color: black;
background-color: red;
padding: 50px 50px 50px 50px;
}
</style>
<script>
$(document).ready(function() {
jQuery("#BottomMarginSelect").change(function() {
jQuery("#CustomDiv").css("margin-bottom",jQuery("#BottomMarginSelect").val());
//alert(jQuery("#CustomDiv").css("margin-bottom"));
});
});
</script>
</head>
<body>
<div id="CustomDiv" class="customDiv">
text in div
</div>--- bottom margin of div ends here (100px below green div border); margin is always transparent ----
<br />
<br />
<b>Select the bottom margin of the div:<b><br />
<select id="BottomMarginSelect">
<option value="10px">10px</option>
<option value="20px">20px</option>
<option value="30px">30px</option>
</select>
</body>
</html>
Selenium.prototype.doStoreStyleAttribute = function(locator) {
var val = selenium.browserbot.getCurrentWindow().document.getElementById(locator).style.marginBottom;
this.doStore(val,"var_style_attribute_from_custom_command");
};
<tr>
<td>select</td>
<td>id=BottomMarginSelect</td>
<td>label=10px</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>id=BottomMarginSelect</td>
<td>var_BottomMarginSelect_select_option_selected_text</td>
</tr>
<tr>
<td>echo</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
<td></td>
</tr>
<tr>
<td>storeStyleAttribute</td>
<td>CustomDiv</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_custom_command}</td>
<td></td>
</tr>
<tr>
<td>assertExpression</td>
<td>${var_style_attribute_from_custom_command}</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@id='CustomDiv']/@style</td>
<td>var_style_attribute_from_id</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_id}</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@class='customDiv']/@style</td>
<td>var_style_attribute_from_class</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_class}</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>CustomDiv@style</td>
<td>var_style_attribute_from_storeAttribute</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_storeAttribute}</td>
<td></td>
</tr>
选择
id=底部边缘选择
标签=10px
存储选择标签
id=底部边缘选择
var\u BottomMarginSelect\u select\u option\u selected\u text
回声
${var\u BottomMarginSelect\u select\u option\u selected\u text}
storeStyleAttribute
海关司
回声
${var\u style\u attribute\u from\u custom\u command}
资产表达
${var\u style\u attribute\u from\u custom\u command}
${var\u BottomMarginSelect\u select\u option\u selected\u text}
storeText
//div[@id='CustomDiv']/@style
变量\样式\属性\来自\ id
回声
${var\u style\u attribute\u from\u id}
storeText
//div[@class='customDiv']/@style
var\u样式\u属性\u来自\u类
回声
${var\u style\u attribute\u from\u class}
storeAttribute
CustomDiv@style
var_style_attribute_from_storeAttribute
回声
${var\u style\u attribute\u from\u storeAttribute}
输出:
<html>
<head>
<script src="jquery-1.6.2.js"></script>
<style type="text/css">
body
{
margin:0px 0px 0px 0px;
}
.customDiv
{
border-style:solid;
border-color: green;
margin: 5px 50px 10px 0px; /* top bottom right left */
margin-color: black;
background-color: red;
padding: 50px 50px 50px 50px;
}
</style>
<script>
$(document).ready(function() {
jQuery("#BottomMarginSelect").change(function() {
jQuery("#CustomDiv").css("margin-bottom",jQuery("#BottomMarginSelect").val());
//alert(jQuery("#CustomDiv").css("margin-bottom"));
});
});
</script>
</head>
<body>
<div id="CustomDiv" class="customDiv">
text in div
</div>--- bottom margin of div ends here (100px below green div border); margin is always transparent ----
<br />
<br />
<b>Select the bottom margin of the div:<b><br />
<select id="BottomMarginSelect">
<option value="10px">10px</option>
<option value="20px">20px</option>
<option value="30px">30px</option>
</select>
</body>
</html>
Selenium.prototype.doStoreStyleAttribute = function(locator) {
var val = selenium.browserbot.getCurrentWindow().document.getElementById(locator).style.marginBottom;
this.doStore(val,"var_style_attribute_from_custom_command");
};
<tr>
<td>select</td>
<td>id=BottomMarginSelect</td>
<td>label=10px</td>
</tr>
<tr>
<td>storeSelectedLabel</td>
<td>id=BottomMarginSelect</td>
<td>var_BottomMarginSelect_select_option_selected_text</td>
</tr>
<tr>
<td>echo</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
<td></td>
</tr>
<tr>
<td>storeStyleAttribute</td>
<td>CustomDiv</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_custom_command}</td>
<td></td>
</tr>
<tr>
<td>assertExpression</td>
<td>${var_style_attribute_from_custom_command}</td>
<td>${var_BottomMarginSelect_select_option_selected_text}</td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@id='CustomDiv']/@style</td>
<td>var_style_attribute_from_id</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_id}</td>
<td></td>
</tr>
<tr>
<td>storeText</td>
<td>//div[@class='customDiv']/@style</td>
<td>var_style_attribute_from_class</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_class}</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>CustomDiv@style</td>
<td>var_style_attribute_from_storeAttribute</td>
</tr>
<tr>
<td>echo</td>
<td>${var_style_attribute_from_storeAttribute}</td>
<td></td>
</tr>
- [信息]执行:|选择| id=BottomMarginSelect |标签=10px|
- [信息]正在执行:| storeSelectedLabel | id=BottomMarginSelect | var_BottomMarginSelect_select_option_selected_text|
- [信息]执行:| echo |${var_BottomMarginSelect_select_option_selected_text}|
- [信息]回声:10px
- [信息]正在执行:| storeStyleAttribute | CustomDiv ||
- [info]正在执行:| echo |${var_style_attribute_from_custom_command}||
- [信息]回声:10px
- [信息]执行:| assertExpression |${var_style_attribute_from_custom_command}|${var_BottomMarginSelect_select_option_selected_text}|
- [info]正在执行:| storeText |//div[@id='CustomDiv']/@style | var_style_attribute_from_id|
- [info]正在执行:| echo |${var_style_attribute_from_id}||
- [信息]回声:页边距底部:10px李>
- [info]正在执行:| storeText |//div[@class='customDiv']/@style | var_style_attribute_from_class|
- [info]正在执行:| echo |${var_style_attribute_from_class}||
- [信息]回声:页边距底部:10px李>
- [信息]正在执行:| storeAttribute |CustomDiv@style| var_style_attribute_from_storeAttribute|
- [info]正在执行:| echo |${var_style_attribute_from_storeAttribute}||
- [信息]回声:页边距底部:10px李>