Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to extract part of a string between two particular characters.
#1
Solved: 11 Years, 4 Months ago
Hi, I have taken the outerhtml of a dropdown present on my webpage, which has 14 questions. now I need to split the questions and take the ubound of the array to count the no of questions present. so I think in the below outerhtml I would need to extract the string between > and ?. how to go about it?/ please help.

Code:
<ul><li role="option" class="x-boundlist-item"><div id="ext-gen1100" class="uw-combo-option">What is the first name of your oldest nephew?</div></li><li role="option" class="x-boundlist-item x-boundlist-selected"><div id="ext-gen1099" class="uw-combo-option">What is the first name of the best man at your wedding?</div></li><li role="option" class="x-boundlist-item"><div id="ext-gen1098" class="uw-combo-option">What was the first name of your first boyfriend/girlfriend?</div></li><li role="option" class="x-boundlist-item"><div id="ext-gen1091" class="uw-combo-option">What was the first name of your first manager? (Enter full name of only)?</div></li></ul>
Reply
#2
Solved: 11 Years, 4 Months ago
If you just want to count the number of questions -
  • Use GetROProperty to fetch the value of the items in dropdown. If for some reason it is not available then
  • You may use split function to split based on ? character . The number of questions would be UBOUND - 1 OR
  • Make use of instr function to locate ? character.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 4 Months ago
Hi, Ankur thanks for the response.

1- the object is not being recognized as weblist but a webedit. so I am confused how can i use GetROProperty("items count"),
2-also if i split the function using ? delimiter it slits the question having a condition with it in two parts, eg "What was the first name of your first manager? (Enter full name of only)" is a single question which gets split in two parts.
Reply
#4
Solved: 11 Years, 4 Months ago
It will helpful if you share the properties and values by using Object spy
Reply
#5
Solved: 11 Years, 4 Months ago
Hi, here are the object's properties :-
Code:
"Class Name:=WebElement",
"abs_x:=502",
"abs_y:=392",
"class:=list-ct",
"height:=257",
"html id:=ext-gen1034",
"html tag:=DIV",
"innerhtml:=<ul><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of your oldest nephew\?</div></li><li role=""option"" class=""x-boundlist-item x-boundlist-selected""><div class=""uw-combo-option"">What is the first name of the best man at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first boyfriend/girlfriend\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first manager\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1036"" class=""uw-combo-option"">What is the first name of your oldest niece\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1085"" class=""uw-combo-option"">What was the name of your first pet\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of the maid of honor at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1084"" class=""uw-combo-option"">Where did you meet your spouse for the first time\? \(Enter full name of city only\)</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1081"" class=""uw-combo-option"">What is the name of the first company you worked for\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1083"" class=""uw-combo-option"">What is your grandfather's nickname\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1080"" class=""uw-combo-option"">What was your favorite restaurant in college\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What street did your best friend from high school live on\? \(Enter full name of street only\)\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your favorite teacher in your final year of high school\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?</div></li></ul>",
"innertext:=What is the first name of your oldest nephew\?What is the first name of the best man at your wedding\?What was the first name of your first boyfriend/girlfriend\?What was the first name of your first manager\?What is the first name of your oldest niece\?What was the name of your first pet\?What is the first name of the maid of honor at your wedding\?Where did you meet your spouse for the first time\? \(Enter full name of city only\)What is the name of the first company you worked for\?What is your grandfather's nickname\?What was your favorite restaurant in college\?What street did your best friend from high school live on\? \(Enter full name of street only\)\?What was the first name of your favorite teacher in your final year of high school\?What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?",
"outerhtml:=<DIV class=list-ct id=ext-gen1034 style=overflow: auto;><ul><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of your oldest nephew\?</div></li><li role=""option"" class=""x-boundlist-item x-boundlist-selected""><div class=""uw-combo-option"">What is the first name of the best man at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first boyfriend/girlfriend\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your first manager\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1036"" class=""uw-combo-option"">What is the first name of your oldest niece\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1085"" class=""uw-combo-option"">What was the name of your first pet\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What is the first name of the maid of honor at your wedding\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1084"" class=""uw-combo-option"">Where did you meet your spouse for the first time\? \(Enter full name of city only\)</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1081"" class=""uw-combo-option"">What is the name of the first company you worked for\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1083"" class=""uw-combo-option"">What is your grandfather's nickname\?</div></li><li role=""option"" class=""x-boundlist-item""><div id=""ext-gen1080"" class=""uw-combo-option"">What was your favorite restaurant in college\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What street did your best friend from high school live on\? \(Enter full name of street only\)\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the first name of your favorite teacher in your final year of high school\?</div></li><li role=""option"" class=""x-boundlist-item""><div class=""uw-combo-option"">What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?</div></li></ul></DIV>",
"outertext:=What is the first name of your oldest nephew\?What is the first name of the best man at your wedding\?What was the first name of your first boyfriend/girlfriend\?What was the first name of your first manager\?What is the first name of your oldest niece\?What was the name of your first pet\?What is the first name of the maid of honor at your wedding\?Where did you meet your spouse for the first time\? \(Enter full name of city only\)What is the name of the first company you worked for\?What is your grandfather's nickname\?What was your favorite restaurant in college\?What street did your best friend from high school live on\? \(Enter full name of street only\)\?What was the first name of your favorite teacher in your final year of high school\?What was the name of the town your grandmother lived in\? \(Enter full name of town only\)\?",
"type:=",
"visible:=True",
"width:=366",
"x:=502",
"y:=329"
Reply
#6
Solved: 11 Years, 4 Months ago
anyone ??
Reply
#7
Solved: 11 Years, 4 Months ago
Why aren't you using innertext to get the desired result?
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#8
Solved: 11 Years, 4 Months ago
ohh yes..thanks Ankur.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to extract particular digit from a string amit25007 3 3,504 10-05-2016, 10:49 AM
Last Post: Ankur
  Spaces and special characters in datatable headings anthony1carr 2 4,233 10-21-2013, 08:33 PM
Last Post: anthony1carr
  Removing ASCII Control Characters from a file Nithin 0 5,681 09-30-2013, 11:45 PM
Last Post: Nithin
Exclamation Retrieve the complete height and width of a browser beyond the visible part as wel learnQtptips 0 2,136 05-22-2013, 09:36 AM
Last Post: learnQtptips
  XML Data read and extract output in an array SweetyChowdhury 9 7,862 05-10-2013, 03:05 PM
Last Post: SweetyChowdhury

Forum Jump:


Users browsing this thread: 1 Guest(s)