javascript - selenium IDE trying to get margin-bottom value -
i'm trying value of bottom margin of element on page. page has select box allows visitor adjust botttom margin of element. want create script changes value , checks bottom margin has been changed. i've done similar thing height parameter there specific assert that. how access bottom margin.
i've tried assertatribute elementid@style
but gives whole stlye includes other values.
i've included height script below although it's not been me
<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>
yah, "storeattribute" command doesn't work well, i've found. found couple different ways it, think using user-extensions best way.
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 transparent ---- <br /> <br /> <b>select bottom margin of div:<b><br /> <select id="bottommarginselect"> <option value="10px">10px</option> <option value="20px">20px</option> <option value="30px">30px</option> </select> </body> </html> create file called "user-extensions.js" , place code in it:
selenium.prototype.dostorestyleattribute = function(locator) { var val = selenium.browserbot.getcurrentwindow().document.getelementbyid(locator).style.marginbottom; this.dostore(val,"var_style_attribute_from_custom_command"); }; set user extensions file in selenium-ide:
options > options >

selenium commands:
<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> output:
- [info] executing: |select | id=bottommarginselect | label=10px |
- [info] executing: |storeselectedlabel | id=bottommarginselect | var_bottommarginselect_select_option_selected_text |
- [info] executing: |echo | ${var_bottommarginselect_select_option_selected_text} | |
- [info] echo: 10px
- [info] executing: |storestyleattribute | customdiv | |
- [info] executing: |echo | ${var_style_attribute_from_custom_command} | |
- [info] echo: 10px
- [info] executing: |assertexpression | ${var_style_attribute_from_custom_command} | ${var_bottommarginselect_select_option_selected_text} |
- [info] executing: |storetext | //div[@id='customdiv']/@style | var_style_attribute_from_id |
- [info] executing: |echo | ${var_style_attribute_from_id} | |
- [info] echo: margin-bottom: 10px;
- [info] executing: |storetext | //div[@class='customdiv']/@style | var_style_attribute_from_class |
- [info] executing: |echo | ${var_style_attribute_from_class} | |
- [info] echo: margin-bottom: 10px;
- [info] executing: |storeattribute | customdiv@style | var_style_attribute_from_storeattribute |
- [info] executing: |echo | ${var_style_attribute_from_storeattribute} | |
- [info] echo: margin-bottom: 10px;
Comments
Post a Comment