Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fing the string in web page
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi All,

I have a string... for eg. "QTP Forum" in a variable 'A'
and i want to find that whether this string exists in a web page?

I have tried to do with 'InStr' function.
but it finds the string in another string.
i want to find the string in a web page....


Thanks,
sia
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
@Sia,

There are three option that you can use for this.

1. You can use the find option on the webpage by using Ctrl+F. You can use the sendkey/Shell object.

2. Use a regular expression to check for this

3. Get the whole page text using
Code:
strBodyText=Browser().Page().Object.Body.innertext
'Now use instr function to see if the text was found or not
If Instr(strBodyText,"<Your Text>")>0 Then
'Found
Else
'Not Found
End IF

Regards,
Ankesh
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi,Ankesh
I m using 3rd logic and it works ... gr8 ...thanks

and also i would love to know how the second logic works
2) use of regular expression ?
Reply
#4
Solved: 11 Years, 4 Months, 3 Weeks ago
Hello All,

I have a script to find a string in a web page.
But my page contains the string at three different position with three different format.
i want to find the string with particular styling(format).

i got this error

Object doesn't support this property or method
Line (10):
Code:
"If Instr(strBodyText,val)>0 Then".

here is my code

Code:
strBodyText=Browser("Jsdl").Page("Jsda").Object.Body.innertext
dim val
set val=WebElement("html tag:=H1","innertext:="&DataTable("categories", dtGlobalSheet))

If Instr(strBodyText,DataTable("categories", dtGlobalSheet))>0 Then
Reporter.ReportEvent micPass,"pass","category found 1"
Browser("Jsdl").Page("Jsdl").WebElement("html tag:=H1","innertext:="&DataTable("categories", dtGlobalSheet)).click
else
Reporter.ReportEvent micFail,"invalid","category not found"
End If

why this error is occuring?

thanks
sia
Reply
#5
Solved: 11 Years, 4 Months, 3 Weeks ago
below statement is wrong

Code:
set val=WebElement("html tag:=H1","innertext:="&DataTable("categories", dtGlobalSheet))

you should use

Code:
Set val=Browser().Page().Webelement()

Now val becomes an object. You can not directly compare its value to a string. Use val.text instead.

I dont see the code for which you have got the error in the code you have posted. Plz post the full code.

Regards,
Ankesh
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  click each web link in a page using Index or other method in QTP smeijer 13 24,820 04-29-2017, 04:53 PM
Last Post: kowshik
  VB Script to count number of links in a web page. Suma Parimal 4 25,377 07-01-2015, 12:59 PM
Last Post: govind
  Replace a string in a word document with another string rekha.naik 8 15,583 11-14-2013, 12:58 PM
Last Post: pranikgarg
  Cannot find the "[ WebButton ]" object's parent "[ Page ]" (class Page) sumitparolkar@gmail.com 4 5,174 05-03-2013, 11:53 PM
Last Post: agarwl.anurag
  How to test a Web page Monica Soneja 3 3,567 04-09-2013, 06:37 AM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 2 Guest(s)