Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

» Selenium IDE Verify different Maps (Hybridview, Mapview etc.)
Fri Nov 25, 2016 9:56 pm by DJ87

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Tutorial for how to use storeEval command to get property of an element.

View previous topic View next topic Go down

Tutorial for how to use storeEval command to get property of an element.

Post by Adviser on Thu Aug 13, 2009 6:53 pm

Hello,

This is asimple way to get a property of web elemnt if you knoen the locator of an element.

NOTE: remember if form name is different it will wont work. All code is tested.


Selenium RC Command are:


1. *for checkBox and radio button*


browser.getEval("javascript:{var status = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.checked; " +
"var val = selenium.browserbot.getCurrentWindow().document.form.*{color:#00ff00}chkPTOPayment*.*value*;" +
"var form = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.form;"+
"var name = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.name;"+
"var type = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.type;"+
"var click = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.click();"+
"var focus = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.focus();"+
"var defaultChecked =Selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.defaultChecked;"+
"alert(status+ \" \" + defaultChecked); }");


2. *for button element*

*note* : add alert box to seevalue of each property
browser.getEval("javascript:{var name = selenium.browserbot.getCurrentWindow().document.form.Image11.name;" +
"var value = selenium.browserbot.getCurrentWindow().document.form.Image11.value;"+
"var type = selenium.browserbot.getCurrentWindow().document.form.Image11.type;"+
"var disabled = selenium.browserbot.getCurrentWindow().document.form.Image11.disabled;"+
"var focus = selenium.browserbot.getCurrentWindow().document.form.Image11.focus();}");


3. *for input field property*

browser.getEval("javascript:{var value = selenium.browserbot.getCurrentWindow().document.form.name.value; " +
"var readOnly = selenium.browserbot.getCurrentWindow().document.form.name.readOnly;"+
"var name = selenium.browserbot.getCurrentWindow().document.form.name.name;"+
"var size = selenium.browserbot.getCurrentWindow().document.form.name.size;"+
"var defaultChecked = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.defaultChecked;"+
"var focus = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.focus();"+
"var blur = selenium.browserbot.getCurrentWindow().document.form.chkPTOPayment.blur();"+
"alert(defaultChecked +\"\t \" + size); }");

4. *for select list property*

browser.getEval("javascript:{var length = selenium.browserbot.getCurrentWindow().document.form1.cboCurrency.length; " +
"var options = selenium.browserbot.getCurrentWindow().document.form1.cboCurrency.options;"+
"var selectedindex = selenium.browserbot.getCurrentWindow().document.form1.cboCurrency.selectedindex;"+
"var text = selenium.browserbot.getCurrentWindow().document.form1.cboCurrency.text;"+
"var focus = selenium.browserbot.getCurrentWindow().document.form1.cboCurrency.focus();"
"alert(text);"
"}" );

5. *for textArea property*

browser.getEval("javascript:{var name = selenium.browserbot.getCurrentWindow().document.form1.txtDesc_1.name;" +
"var readOnly = selenium.browserbot.getCurrentWindow().document.form1.txtDesc_1.readOnly;"+
"var size = selenium.browserbot.getCurrentWindow().document.form1.txtDesc_1.size;"+
"var type = selenium.browserbot.getCurrentWindow().document.form1.txtDesc_1.type;"+
"var value = selenium.browserbot.getCurrentWindow().document.form1.txtDesc_1.value;"+
"alert( type + \"\t\" + value);"+
"}");




6. *property for form method*

browser.getEval("javascript:{var action = selenium.browserbot.getCurrentWindow().document.form1.action;" +
"var elements =selenium.browserbot.getCurrentWindow().document.form1.elements;"+
"var length =selenium.browserbot.getCurrentWindow().document.form1.length;"+
"var method =selenium.browserbot.getCurrentWindow().document.form1.method;"+
"var submit =selenium.browserbot.getCurrentWindow().document.form1.submit();"+
"alert(elements);"
+"}");


Try to be more creative and used this way to get complex reult and tell me also how to go futher.


Best of luck.
GOD BLESS U ALL

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum