cancel
Showing results for 
Search instead for 
Did you mean: 

Why the find method cannot see the text on the page?

SOLVED
Frequent Contributor

Why the find method cannot see the text on the page?

Hi everyone,

 

I have this vbscript here looking some text on a webpage, it keeps telling me that the property value was not found, but I can see the text I want to verify is right there on the page. Can anyone help me why it cannot see it?

Capture.JPG

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Leader

Re: Why the find method cannot see the text on the page?

You can find using partial text.  You will just need to use regex in you propertu values e.g.

 

Page.Find("contentText","regexp:(Your password has been)",100).Exists

-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: Why the find method cannot see the text on the page?

Hi,

 

> it can't find partialy text?

You can use wildcards. E.g. :

Page.Find("contentText","Your password has been*",100).

 

> I find out Edge was running in process, but I didn't launch it at all. [...] Any idea why is that?

This is because in order to improve start time (and, possibly, do some other things that they think they must do disregarding your opinionSmiley Wink ) a lot of overly smart modern applications continue to run in the background after you explicitly close them. Smiley Happy

Solution: https://answers.microsoft.com/en-us/edge/forum/all/why-is-edge-running-when-i-have-not-opened-it/76c...

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
9 REPLIES 9
Highlighted
Community Hero

Re: Why the find method cannot see the text on the page?

Hi,

 

Is this the only browser process that runs in your system?

Note, that as browser name and page address are wildcarded in your code, TestComplete will pick-up any browser that it finds first, get a reference to any page opened in this browser and try to search within this page.

So if you have more than one browser, the chances are high that some other but assumed browser and page are used for search.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Leader

Re: Why the find method cannot see the text on the page?

Your find string in the find method doesn't have the exact same text as the contentText.  the one has a trailing "."

 

Either add the "." to your find method or remove the "." from your page.  I'm guessing it's the latter.  If you really don't know if the "." will be there or not, try finding the leading string with Regex


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Frequent Contributor

Re: Why the find method cannot see the text on the page?

Thanks. After I added the "." to my script, it can find the text now.  But then I am wondering it can't find partialy text?

Frequent Contributor

Re: Why the find method cannot see the text on the page?

Hi Alex,

 

Yes, Chrome was the only browser that was running, after I updated my script, it now can find the text but with warning "Ambiguous browser recognition". I find out Edge was running in process, but I didn't launch it at all. I will have to kill the Edge from process in order to pass the test. Any idea why is that?

Untitled.png

Community Leader

Re: Why the find method cannot see the text on the page?

You can find using partial text.  You will just need to use regex in you propertu values e.g.

 

Page.Find("contentText","regexp:(Your password has been)",100).Exists

-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Frequent Contributor

Re: Why the find method cannot see the text on the page?

Thank you!

Community Leader

Re: Why the find method cannot see the text on the page?

Just in support of what @AlexKaras said regarding browsers.  Using sys.browser in some instances is the only option, but that is rare.  Generally it's better to use aliasing so you can use Aliases.Browser.Page, which helps figure out the browser itself by means of the way your tested app is configured.

If you find you must use the browser rather than the aliased object, consider using CurrentBrowser rather than Browser("*")

 

If you get ambigous browser detection your test will probably keep running, but the performance impact will be tremendous, because TC may be checking for the specified item in all open browsers before getting to the correct one.

 

If you aren't using crossbrowser, consider using Browser("iexplorer") or Browser("edge") etc.

That will return only one instance for TC to search for the page.  It might still be the wrong browser though if you have more than one browser process by that name running.  For that you will want to turn to the solution @tristaanogre initially posted:  Always terminate all your browser proccesses before starting your test and make the first step of any test starting up a new browser.  Code as follows (jscript) - will need some extending/changing:

 

var counter = 0;
var browser = Sys.WaitBrowser("iexplore",1000); //or "edge", chrome etc.

while(browser.Exists && counter<60)
{
 counter++;
 browser.Terminate();
  browser = Sys.WaitBrowser("iexplore",1000);
}

This should ensure you always have only the one single instance of the browser you are working with


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Community Hero

Re: Why the find method cannot see the text on the page?

Hi,

 

> it can't find partialy text?

You can use wildcards. E.g. :

Page.Find("contentText","Your password has been*",100).

 

> I find out Edge was running in process, but I didn't launch it at all. [...] Any idea why is that?

This is because in order to improve start time (and, possibly, do some other things that they think they must do disregarding your opinionSmiley Wink ) a lot of overly smart modern applications continue to run in the background after you explicitly close them. Smiley Happy

Solution: https://answers.microsoft.com/en-us/edge/forum/all/why-is-edge-running-when-i-have-not-opened-it/76c...

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Leader

Re: Why the find method cannot see the text on the page?


@AlexKaras wrote:

Hi,

 

> it can't find partialy text?

You can use wildcards. E.g. :

Page.Find("contentText","Your password has been*",100).

 


That will work just as well and is simpler syntax Smiley Happy


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors