Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

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

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
Back to top
Permissions in this forum:
You cannot reply to topics in this forum