SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Using "storeXpathCount" in selenium ide with example

To understand how to use "storeXpathCount" command, you must be aware about xpath. You can read xpath tutorials for selenium ide in my previous post if you are not aware about what is the xpath of element and how to retrieve it manually. "storeXpathCount" command is useful to calculate and store number of
matching nodes for the given xpath in target field. Here i have used word number of matching nodes not all nodes. Let we learn it with example so you can get better idea.

Selenium IDE "storeXpathCount" command example



Look in to above given screenshot.There are total 5 child nodes(4 'input' nodes and 1 'select' node) inside the 'fieldset' parent node. Look in to the bellow given examples.

New Test
CommandTargetValue
openhttp://www.wikipedia.org/
storeXpathCountxpath=//body/div[3]/form/fieldsetfieldsetcount
echo${fieldsetcount}
storeXpathCountxpath=//body/div[3]/form/fieldset/*fieldsetinsidecount
echo${fieldsetinsidecount}
storeXpathCountxpath=//body/div[3]/form/fieldset/inputinputcount
echo${inputcount}
storeXpathCountxpath=//body/div[3]/form/fieldset/selectselectcount
echo${selectcount}
Example 1 : "storeXpathCount" command for 'xpath=//body/div[3]/form/fieldset' will return and store 1 into variable = 'fieldsetcount' because there is only one matching node available on fieldset node level.

Example 2 : Now 2nd example is wild card. "storeXpathCount" for "xpath=//body/div[3]/form/fieldset/*" will  store 5 into variable = 'fieldsetinsidecount'. It will calculate and store total numbers (4 input nodes and 1 select node) of child nodes inside parent node "fieldset".

Example 3 : Same way it will check total no of child nodes for parent "fieldset" where node name = input for "xpath=//body/div[3]/form/fieldset/input". It will store 4 in to variable = "inputcount".

Example 4 : There is only 1 "select" node inside parent node "fieldset". So it will store 1 in to variable = "selectcount" for xpath=//body/div[3]/form/fieldset/select.

No comments:

Post a Comment