Forum Discussion
I'm going to try my best to explain the following scenario - I'm using your code to search for SubmitX button on website https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select which does not exist.
I'm going to pass in the following values into the method, CheckForExists(page, 3),
function main()
{
// URL https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
var page = Sys.Browser().Page("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select").FindElement("#iframeResult");
CheckForExists(page, 3);
}
function CheckForExists(objElement, intSecondsToDelay)
{
let intTimeOut = Options.Run.Timeout;
Log.Message("Check for exists " + Options.Run.Timeout);
Options.Run.Timeout = 1000;
let intSecondsWaited = 0;
Log.Message("starting do loop");
do
{
intSecondsWaited ++;
Log.Message(Options.Run.Timeout);
// Find SubmitX button, which does not exist
if (objElement.FindElement("//input[@value='SubmitX']").Exists)
{
Log.Message("object exists");
break;
}
else
{
Log.Message("object does not exist");
}
Log.Message(intSecondsToDelay);
Log.Message(intSecondsWaited);
}
while (intSecondsWaited < intSecondsToDelay);
}
and Options.Run.Timeout = 1000, which sets the following project value,
When I run the code, it's waited 1000ms for the object to become available, as shown in Error. Since we set parameter intSecondsToDelay = 3, we can say it waited for 3 seconds (I'll get back to this point)
Now, if I pass CheckForExists(page, 2) and Options.Run.Timeout = 30000. When I run the code, it's waited 30000ms for the object to become available, as shown in Error lines. Since we set parameter intSecondsToDelay = 2, we can say it waited for 2 seconds. However, we can clearly see that it hasn't waited for 2 seconds, it's done 2 iterations of the loop, waiting 30 seconds each. Therefore, the total time it took was about 1 minute to complete.
In your example, it seems like Options.Run.Timeout is not settings the value correctly; performing 15 iterations and waiting 30 seconds each time.