How to create custom script for dynamic wait for desktop and web
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to create custom script for dynamic wait for desktop and web
Hi,
I see there are Different waits in selenium for web and desktop but i want to use one custom method for having smart wait like we have in selenium.
can someone give a sample of custom function which i can call for desktop and web differently.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not being very familiar with Selenium, what do you mean by "different waits"? Waits for what?
In TestComplete there are a variety of ways of waiting for an object, page, component, etc., all built in to the various parts of the tool. If you can describe a bit more as to what you're looking for in the way of examples, scenarios, someone can probably give you at least a start f what you're looking for. Most likely, such a thing will utilize one or more of those existing waits in TestComplete.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am looking to put dynamic wait in multiple places until an object is let's say visible or enabled to perform actions.
Suppose wait time is 10sec but if object loaded in 3sec then it will move on not wait further 7 sec
and I want to have a custom function where I just pass the object and time, then call this function from wherever i needed for whichever object.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any reasons for not wanting to use Waiting for an Object, Process or Window Activation?
You can create a function that accepts an object, within the function have a while statement that checks the state of the object. You can also include a time out period too.
There's also a few examples on the forum.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Almost all the built in Wait functions that @rraghvani linked to already do that. WaitAliasChild, WaitChild, WaitProcess, etc, all operate as a "timeout" where you set a value (10 seconds in your example) but it only waits as long as necessary.
I'd start looking there, rather than building an extra custom function.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
to many places i had to put wait so looking for custom function.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're still going to have to put that custom function in just as many places.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If in your scipt, you want to wait for 10 objects to appear, then you'll use one of appropriate WaitNNN Methods, 10 times for each object.
Or you could spend time, writing your own custom function, then call it 10 times for each object.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have created this kind of method. I've called it "fluentWait". (I use javascript)
this method wait dynamically for an object to be exists in the object tree. (100ms interval, up to 10sec)
function fluentWait(){
let stopTime = GetTickCount() + 10000; //wait 10s at max
do {
var obj = Aliases.your.main.container.WaitNamedChild(MappedChildName, 100);
}
while(! obj.Exists && GetTickCount() < stopTime);
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using WaitNamedChild Method achieves the same - "Use the WaitNamedChild method to delay the test execution until the specified mapped child object appears in the child list of the given mapped object or the specified time limit is reached". I.e.
Aliases.your.main.container.WaitNamedChild(MappedChildName, 10000);
