My use case: I am testing the execution of a SharePoint workflow which may take up to 10 minutes to complete. When this workflow completes, a refresh of the page will add an object which I have defined in my repository, and can then test for the object's existence.
The challenge I face is, I need to do what amounts to a "Do...Until" loop, where Ranorex will periodically refresh the page with an F5, once each minute would be fine, and test for the repository item to exist or not. If the object is not found after 10 minutes, fail the test.
How can I accomplish this?
how to periodically refresh browser and test for existence?
-
- Posts: 2
- Joined: Fri Oct 09, 2015 5:44 pm
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: how to periodically refresh browser and test for existence?
Hello amccollough,
I would suggest implementing a User Code Action, which checks periodically if the object exists.
Please take a look at the sample method below.
Depending on your specific use case you probably have to modify the source code.
Prerequisites for the implementation below are two repository items:
1) The DOM-element, which contains the Sharepoint application
2) The Object, which needs to be checked
Please let me know if you need further assistance.
Regards,
Johannes
I would suggest implementing a User Code Action, which checks periodically if the object exists.
Please take a look at the sample method below.
Depending on your specific use case you probably have to modify the source code.
Prerequisites for the implementation below are two repository items:
1) The DOM-element, which contains the Sharepoint application
2) The Object, which needs to be checked
Code: Select all
public void CheckIfObjectExists()
{
bool objectExists = false;
//Try to reload and search for the element ten times
for ( int i = 0; i<=10 && objectExists == false; i++)
{
//Reload the current web page
repo.Sharepoint.Self.ExecuteScript("location.reload(true);");
//Check whether the object exists
objectExists = repo.Sharepoint.ObjectInfo.Exists(3000);
if ( objectExists == true )
{
//Objects exist, no more iterations needed
Report.Success("Object exists.");
}
else
{
//Object does not exist, wait for one minute and continue search
Report.Info("Object does not exist. Wait and reload page.");
Delay.Seconds(60);
}
}
if ( objectExists == false )
{
Report.Failure("Object does not exist");
}
}
Regards,
Johannes
-
- Posts: 2
- Joined: Fri Oct 09, 2015 5:44 pm
Re: how to periodically refresh browser and test for existence?
I do need help with this. You say I need two repository items, but exactly how do I pass those into the user code? I tried playing with the Args, and see from other online examples I can use Adapter or RepoItemInfo, but which?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: how to periodically refresh browser and test for existence?
Hello amccollough,
In the sample above the repository items are accessed directly from the repository, which is available as the 'repo'-object within recording modules.
More information about using the repository within user code can be found in the user guide.
As you mentioned, another way would be to add parameters to the user code actions.
Please use the type 'Adapter' for the DOM-element and 'RepoItemInfo' for the corresponding object.
In this case you have to cast the DOM-element in order you can run the ExecuteScript()-method.
If you pass the items as arguments you have to adjust the code sample.
In this case, please useinstead of
and
instead of
Please let me know if you need more information.
Regards,
Johannes
In the sample above the repository items are accessed directly from the repository, which is available as the 'repo'-object within recording modules.
Code: Select all
repo.Sharepoint
repo.Sharepoint.Object
As you mentioned, another way would be to add parameters to the user code actions.
Please use the type 'Adapter' for the DOM-element and 'RepoItemInfo' for the corresponding object.
In this case you have to cast the DOM-element in order you can run the ExecuteScript()-method.
If you pass the items as arguments you have to adjust the code sample.
In this case, please use
Code: Select all
domElement.As<WebDocument>().ExecuteScript("location.reload(true);");
Code: Select all
repo.Sharepoint.Self.ExecuteScript("location.reload(true);");
Code: Select all
objectExists = testObject.Exists(3000);
Code: Select all
objectExists = repo.Sharepoint.ObjectInfo.Exists(3000);
Regards,
Johannes
You do not have the required permissions to view the files attached to this post.