Regular expressions for web testing

Browser("Yahoo! Mail: The best").Page("(2 unread) Yahoo! Mail").Link("Inbox (2)").Click

this is the recorded script i get after performing the action on yahoo mail..now when i run the test again ...the page title and link name changes as the no. of emails in inbox increases...so the error says cannot find the object.

can someone please tell me what regular expressions i should used for this script ?

Questions by anushankar   answers by anushankar

Showing Answers 1 - 18 of 18 Answers

Use the following code which suites your inquiries


Browser("title:=.*Yahoo!.*").Page(".*Yahoo!.*").Link("Inbox.*").Click

Try this and let me know if it executed properly


Ramu

  Was this answer useful?  Yes

Please use descriptive programming laguage. Your code should look like something as below

Browser("name:=.*Yahoo!.*","title:=.*Yahoo!.*").Page("title:=.*Yahoo!.*").WebTable("name:=login").WebEdit("name:=login").Set "XYZ"

Use object spy tool in QTP to learn the properties of the object and use them in desciptive language. I hope it should help you

  Was this answer useful?  Yes

Instead of "2 unread", you can regularise the option with a regular expression as [0-9]* in the palce of 2 and do not forget to check the regular expression check box.

  Was this answer useful?  Yes

Browser("Yahoo! Mail: The best").Page("(2 unread) Yahoo! Mail").Link("Inbox (2)").

we can resolve this issue by Regular Expresions. In the Object Repository change the Value of the object using .* and save the change in the Object Repository.

eg) Page("(2 unread) Yahoo! Mail") --> instead of this (2 unread) Yahoo! Mail) object change the object to a common name wih .*

this can be handled even using Descriptive Programming by give the Value of a unique property in the Code itself

  Was this answer useful?  Yes

Today I tried after read your question. You know what I did, I just changed the object name in the object repository file.ie.
when you are recording if is inbox(4), then running it must be inbox(3) in the application.
so go to resource->object repository-> and change inbox(4) as inbox(3) in object name (inbox(4) will come when you expand object tree in repository file). then it is recognising the object and working fine.
please let me know if it is wrong, I am a beginner.

  Was this answer useful?  Yes

allen hu

  • Jun 12th, 2010
 

You do not need to change anytihng in your scripts.

But you need find that link in object repository and update the value of the attribute display in it which to identify the object, such as 'innertext'.

You need regular expression of this value in order to make the QTP can smart indentify the object.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions