JStudio SiteWalker Service Board Forum Index JStudio SiteWalker Service Board
Find out / share information about our product, experience and requirements. To serve all user all postings must be written in English language. We are looking for constructive meanings and experience. Disrespectful postings will be deleted immediately.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extracting parts of text from a text?

 
Post new topic   Reply to topic    JStudio SiteWalker Service Board Forum Index -> General Issues: Testing automatically
View previous topic :: View next topic  
Author Message
chrisdutz



Joined: 27 Jun 2006
Posts: 7

PostPosted: Tue Jun 27, 2006 1:57 pm    Post subject: Extracting parts of text from a text? Reply with quote

Hi,

I am currently building my first bigger Sitewalker Testcase and ran into the following Problem.

I have a page containing mainly list-data. The title is of the folowing structure: "LADUNGEN ({number of results}) ({time the page was served})" I would like to extract the {number of results} part in order to compare it with the results delivered after applying some filters. How is this done?

Regards,
Chris
Back to top
View user's profile Send private message
sitewalker
Site Admin


Joined: 09 Feb 2006
Posts: 39

PostPosted: Wed Jun 28, 2006 12:55 pm    Post subject: manipulate & format contents with JavaScript Reply with quote

Hi chrisdutz,

thank you for your interest in JStudio SiteWalker.

You can do the follwing:

1. To extract text just find out the HTML element containing the text/ sourcecode. If it is displayed within the browser, just click on it. If not displayed find it in the document structure pane manually.

2. To extract a string part from the complete displayed text/ source code you have to specify a JavaScript doing the job. The following example shows how to extract 190 chars from the left of a your posting text and to change the displayed text of the element. To test it, just copy the code, switch to ScriptEditor, enter it and execute it against the page of this posting be selecting it from select box.

The script could look like:


Code:
function Left(String1, Length)
{
   if (String1 == null)
      return (false);
   return String1.substr(0, Length);
}


// overwrites the displayed text of an element
document.getElementsByTagName("SPAN")[12].innerText = Left(document.getElementsByTagName("SPAN")[12].innerText, 190);


So if you had applied the 12th SPAN (which includes your posting text) as a step the ramaining text can be saved to Microsoft Excel and used for comparison purposes. To use Excel cell for validation comparison, please use Excel button on assertion definition within the Quick Validator.

Because your step saves extracted content to Excel those values can be used for validation.

Please Note: This is just a simple Example. Using JavaScript you can define more complex string manipulation functionality. Please refer to the delivered Example file Tutorial_EXample in your SiteWalker\Example folder. The task String Manipulation shows how to use JavaScript and to execute it during auto navigation. Anything can be done by JavaScript.

Hope, these suggestions might help you to overcome the problem.

Enjoy working with JStudio SiteWalker

regards,

Frank
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    JStudio SiteWalker Service Board Forum Index -> General Issues: Testing automatically All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group