Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium WebDriver Integration
Today at 1:06 pm by azharuddin

» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

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
avatar
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


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