Forum Discussion
Hi,
Personally I am not sure that the idea with event is the best one.
What is the goal of your verification?
From your explanation I got it that you'd like to check that url contains certain data after certain action. Why not to explicitly check this by combining an action and verification into one function and do not bother about event that can be triggered at some other moment?
It is possible to inject arbitrary code into web page (https://support.smartbear.com/testcomplete/docs/app-testing/web/common-tasks/javascript.html) and bind this code to browser-specific event (like page load), but again, my preference is the explicit check for explicit action as it is usually done with testing: you plan action, you perform action, you check for the expected result.
Thanks for the reply, yes I understand all this, thank you.
For the select test cases we have where this does get triggered, I have already implemented an action and assertion for the data item using javascript to get the URL at time of action (or shortly after a property checkpoint).
What I am looking to verify is actually the non-existence of the data item across the whole site and hundreds of tests we currently have.
As these actions are already written, I don't particularly want to go in and add an assertion at each point where I know the URL changes and thus eligible for a check.
- Marsha_R3 years agoChampion Level 3
Instead of trying to piggyback this on the other tests, you could have a separate test that does nothing but run through the web pages and trigger this URL change and check for it there.
- AlexKaras3 years agoChampion Level 3
Hi,
If you still prefer to try with events...
Somewhere in time there was Support article on how to embed different script types into web page. Find it attached. It is outdated and requires update (at least Page.Application must be replaced with Page.contentDocument) and thus is not available on the site, but you may give it a try. Especially the "Embedding Event Handlers into Web Pages" section.
The general idea is like that:
-- Consult Chrome (Chromium?) documentation and find an event suitable for your case;
-- Create a function that will obtain url value from the page via native DOM means (not methods/properties provided by TestComplete as this function will be executed in the context of a page but not in a context of TestComplete);
-- Attach this function to the event using code sample from the article;
-- Function must communicate its result to TestComplete somehow: either via global variables, like in the article, or, maybe, via some alert message, or think about some other approach that might work for you.
The last step looks most challenging but hope you will work out a decision that will work for you.
Related Content
- 10 months agorstelly