Searching for text
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Searching for text
TIA - Dave
Got the findallchildren logic working, but still seems cludgey
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you have to search just for a single object? If you do, you can use the Find method in a loop until the object appears. Find returns a single object, not an array as FindAllChildren does. You just need to specify the property name, the text this property returns and a depth large enough (usually, 10 - 20 should do).
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
What if I want to find a text that is a date, which changes every day. Basically, I have a string that shows today's date + 1 day, and I have to check if this in fact today's date + 1 day. How can I do that?
Thank you,
Andrei
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Andrei,
Please post here the HTML text of the object containing this date. The HTML code is stored in the 'outerHTML' property of this object.
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello David,
Here is the HTML text:
"<SPAN style="" id="ctl00_ContentPlaceHolder2_ucRegistrationStep2_lbBillingCondition">$5 1-day trial. <BR/><BR/>Your $5 1-day trial lasts until midnight on 4/23/2010. After your 1-day trial ends, your credit card on file will be charged the regular price of $25 per month for ............... </SPAN>"
The text I want found is "4/23/2010" which changes daily.
Thank you,
Andrei
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend that you search for this object by its 'id' attribute. Here is a script demonstrating this:
...
var page = ...;
var obj = page.FindChild("NativeWebObject.id", "*_ucRegistrationStep2_lbBillingCondition", 100);
if (false == obj.Exists) {
Log.Error("The Billing Condition label is not found.");
}
...
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
-Pv-
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Paul,
I meant the Page object (Sys.Process("iexplore").Page("*") or Aliases.iexplore.pageMyPage), but this can be any of the parent objects of the sought-for object.
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help.
I tried this...
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 12" name="Generator" />
<meta content="Microsoft Word 12" name="Originator" />
var MyItem =
Item_LocateInPage(Aliases.Sys.iexplore.pageStarlightLicenseServer20.document.all,
if(MyItem !=
null) {MyItem.Click()}
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 12" name="Generator" />
<meta content="Microsoft Word 12" name="Originator" />
function Item_LocateInPage(TREE_MODEL_OBJECT, SearchText)
{Log.Message("Item_LocateInPage")
if(TREE_MODEL_OBJECT.ChildCount < 1)
{Log.Message("No " + TREE_MODEL_OBJECT + " Children
Detected in search"); return null}
Log.Message("Searching " + TREE_MODEL_OBJECT.ChildCount +
" children...");
var obj =
TREE_MODEL_OBJECT.FindChild("NativeWebObject.outerText", SearchText,
100);
if (false ==
obj.Exists)
{
Log.Error(SearchText + " not found.");
return null;
}
else
return obj;
}
Results:
Item_LocateInPage
Searching 764 children...
sdfg not found.
I also tried:
var MyItem =
Item_LocateInPage(Sys.Process("iexplore",
2).Page("http://127.0.0.1:3000/").document.all,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may not be able to tell from the image the item I'm trying to click is a direct child of the Object Tree .all, so should be able to find within 100 layers?
-Pv-
