Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18120 Posts in 4741 Topics- by 31743 Members - Latest Member: suuraj
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Webelements issue?    (Read 185 times)
Madhu S
Active User
**
Offline Offline

Posts: 84


« on: February 05, 2010, 04:14:20 AM »

Hi,
    I want to retrive the names of the Webelemts(like Welcome,Sigin or Register)will find in the aplication top.
Here we can store/save in OR retrive with the Getroproperty(Innertext/Outertext)..after split function will see one by one.
Its normal approach.
But i want to do with DOM Concept.In my source code that element having the

<div class="userInfo">Welcome,

I want to retrive Welcome frm sourcecde,hw can i ?

I tried using GetelemntByName,ID,TAGNAME,its not working.

Pls help me ?

Regards
Madhu

Logged
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #1 on: February 05, 2010, 04:35:12 AM »

Hi Madhu,
     Try the below code,

Code
GeSHi (qtp):
divCount=Browser().Page().Object.GetElementsByTagName("Div").Length-1

For i=0 to divCount

If Browser().Page().Object.GetElementsByTagName("Div")(i).Innertext="Welcome" Then

Exit For

End If

Next



Msgbox "The Div index is: "& i

 
Created by GeSHI 1.0.7.20

Please post the HTML code of the div tag. So that I can write the exact code for you.

I hope this helps you Smiley
Logged
Madhu S
Active User
**
Offline Offline

Posts: 84


« Reply #2 on: February 05, 2010, 05:12:21 AM »

Hi Asiq,I tried this ..its not giving the expected result

Iam attaching the s.code

Logged
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #3 on: February 05, 2010, 05:27:48 AM »

Hi Madhu,
       Convert the attached text file into HTML file and try the script with the HTML file. You will get the inner text of the DIV tag.

Code
GeSHi (qtp):
Msgbox Browser("name:=QTP Codes").Page("title:=QTP Codes").Object.getElementsByTagName("DIV")(0).InnerText'Make sure about index of your div when you try this code with your webpage.

 
Created by GeSHI 1.0.7.20

Please let me know if you face any issues.

Logged
Madhu S
Active User
**
Offline Offline

Posts: 84


« Reply #4 on: February 05, 2010, 05:42:55 AM »

Earlier textfile i changed to Html,its dispalying Welcome .But in sopurce code i did not find Anyindex for that.Wen i coded below like

divCount=Browser(" for").Page("for").Object.getElementsByTagName("div").length


For i=1 to divCount

   
b=Browser("for").Page("for").Object.getElementsByTagName("div")(i).innertext

MsgBox b

next

at first iteration i got Like attached Dialogbox.In that othertextwith Welcome,Sign IN or Register.





Logged
Madhu S
Active User
**
Offline Offline

Posts: 84


« Reply #5 on: February 05, 2010, 05:51:03 AM »

Hey Asiq ,got it .At second iteration i got that message after running more iteration i gopt the exact result its worked.
Yes ,Index is required.I given that iteration number in the code ..its directly given the result also.Its works.

Super thanks Asiq.

 Convert the attached text file into HTML file and try the script with the HTML file. You will get the inner text of the DIV tag.

Try SCRIPT with HTML FILE ..How can i do,i dont know this approach?will u pls Asiq.
Logged
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #6 on: February 05, 2010, 06:02:47 AM »

Glad you resolved it Smiley

Quote
Try SCRIPT with HTML FILE ..How can i do,i dont know this approach?will u pls Asiq.

I couldn't attach HTML file in this forum, that's y I had requested you to convert text file into HTML file. So that you are able to compare the code with this sample webpage to your web page. This is not new approach or method. I have just created a sample HTML file with DIV tag and I have retrieved the innertext of the DIV with below snippet.

Msgbox Browser("name:=QTP Codes").Page("title:=QTP Codes").Object.getElementsByTagName("DIV")(0).InnerText

Thanks,
Asiq
Logged
Madhu S
Active User
**
Offline Offline

Posts: 84


« Reply #7 on: February 05, 2010, 07:34:58 AM »

Oh,ok.That's great.Sorry fr late reply ..surfing is diconneted.

Asiq,now my issue is cleared.Pls close the ticket.


Thanks Alot once again,fr ur support.

Regrads

Madhu
Logged
Pages: [1]   Go Up
Print
Jump to: