Why the find method cannot see the text on the page?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Thanks
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 opinion;) ) a lot of overly smart modern applications continue to run in the background after you explicitly close them. 🙂
/Alex [Community Champion]
____
[Community Champions] 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. Posts made by [Community Champions]
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.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
-------------------------------------------------
Standard syntax disclaimers apply
Regards,
