Share
Go down
Priyanka
Regular Participant
Regular Participant
Posts : 27
Join date : 2010-10-04

How to get the count of repeated word from the bodytext?

on Wed Oct 13, 2010 2:28 pm
Hi,

I used selenium.getBodyText();

An example is given below
Mr ggg ggg DM Petrol QATEST 12:45:52
Mr lom sd QATEST 12:43:38
Mrs oui uio Enquiry about ... DM Diesel QATEST 12:36:34

The word QATEST is repeated in the bodytext. How can I get the count of that word from the bodytext?

FYI: Am writing selenium script using C#.
Please help..Tnx in advance
avatar
Advisor
------------------------
------------------------
Posts : 383
Join date : 2009-07-30
Location : India
http://seleniumforum.forumotion.net

Re: How to get the count of repeated word from the bodytext?

on Fri Nov 26, 2010 11:17 pm
Hi,

Yes you can do it very easily. Follow the steps:

1. get the page source code into a string variable.
2. now use the inbuilt function of strings which found the occurrence of particular string into that string
ex: Console.WriteLine(TextTool.CountStringOccurrences(s1, "Sam"));
3. now you have number of count.

wohooooo...............this is what you want. Hope this will help

Best of luck

Bye

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