The area I'm writing a test for involves a progress label. This label updates itself during a check of a SharePoint farm. It updates with messages like:
Processing: MySPSite
which changes to:
Processing: MySecondSPSite
and so on until it goes through all sites on the SP farm. Finally, when it finishes, the label shows:
Processing has completed
Now, the processing can take anywhere from 30 sec to upwards of 45 min. and higher, based on the size of the farm. What I'm trying to do is set a Validation task at the end, that checks for successful completion. I need the automation to wait (for as long as it takes) until those words 'Processing has completed' appear in the label. In the absence of any other state changes on the UI (only the label text changes), how can I get those words to act as a trigger? I can't simply put in a delay, because the processing might take shorter or longer than the delay will allow. Any ideas? Thanks!
how to check for label state change
Re: how to check for label state change
u can try this :
Boolean flag_found=false;
do
{
flag_found=Validate.Exists("./form//label[@id~'.*complete$']",5000,"Check Object '{0}'",false);
} while (flag_found);
It will wait for 5Seconds every time and checks for the Id of the Label element.
Boolean flag_found=false;
do
{
flag_found=Validate.Exists("./form//label[@id~'.*complete$']",5000,"Check Object '{0}'",false);
} while (flag_found);
It will wait for 5Seconds every time and checks for the Id of the Label element.
Re: how to check for label state change
Something very simple. (You'll need to verify the exact attribute type you want grab from the label element)
Code: Select all
while (MyLabelElement.TextValue.ToString() != "Processing has completed")
{
Thread.Sleep(500);
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: how to check for label state change
I wouldn't use a loop without a timeout...
Am I missing something? Can't you just do?
Am I missing something? Can't you just do?
Code: Select all
Validate.Exists("./form//label[@id~'.*complete$']",60000 * 45);
Re: how to check for label state change
Quite true... This was just a quick snippet of code to show one way how they could do what they were looking for... But if you want to extend this, I also wouldn't do something like this outside of a try/catch and a little bit more error handling...sdaly wrote:I wouldn't use a loop without a timeout...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: how to check for label state change
Thank you all for your replies. I get the drift of what you are suggesting, but I'm having difficulty implementing it. The label in question I've renamed ExecXML_Status, and its path in the repository is:
.//span[#'ctl00_lblStatus']
The current version of the validation involves checking the InnerText (which is a WebElement) to make sure the word "errors" does not appear there, after a delay. The validation code is:
Validate.Attribute(repo.ExecuteSavedInstructions.ExecXML_StatusInfo, "InnerText", new Regex("^((?!("+Regex.Escape("Errors")+")).)*$"));
I guess ultimately I'm wondering how to take this validation and turn it into one of the several suggestions posted to this question. Thanks again!
.//span[#'ctl00_lblStatus']
The current version of the validation involves checking the InnerText (which is a WebElement) to make sure the word "errors" does not appear there, after a delay. The validation code is:
Validate.Attribute(repo.ExecuteSavedInstructions.ExecXML_StatusInfo, "InnerText", new Regex("^((?!("+Regex.Escape("Errors")+")).)*$"));
I guess ultimately I'm wondering how to take this validation and turn it into one of the several suggestions posted to this question. Thanks again!
Re: how to check for label state change
Something like this? As discussed before, you should add a timer and enclose all this with error handling...
Code: Select all
bool boolFailure = false;
while (ExecXML_StatusInfo.InnerText.ToString() != "Processing has completed")
{
if (ExecXML_StatusInfo.InnerText.ToString().contains("error")
{
Report.fail("The following error occurred. " + ExecXML_StatusInfo.InnerText.ToString());
boolFailure = true;
break;
}
Thread.Sleep(500);
}
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: how to check for label state change
That definitely makes sense, but my problem seems to be that I can't access InnerText in that fashion. It appears that I can only get to ExecXML_StatusInfo thru the repository:
repo.ExecuteSavedInstructions.ExecXML_StatusInfo
and InnerText isn't showing in the drop-down from there in the IDE. So your method makes perfect sense, but I'm hamstrung by the fact that I can't access the InnerText easily.
repo.ExecuteSavedInstructions.ExecXML_StatusInfo
and InnerText isn't showing in the drop-down from there in the IDE. So your method makes perfect sense, but I'm hamstrung by the fact that I can't access the InnerText easily.
Re: how to check for label state change
Hmm, a SpanTag should have an innettext attribute. I must be missing something...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: how to check for label state change
Perhaps I'm referencing it incorrectly? It's just, the only way I can think of referencing that element is through the repo. If there's another way to reference it, I'd be eager to hear it. That would certainly make things for me much easier. Thanks again!
Re: how to check for label state change
Well, I don't use the repository so I can be of no help there. Sorry...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: how to check for label state change
I think I've figured it out - I was referring to ExecXML_StatusInfo, where it really should be just ExecXML_Status. I believe using that should get me to the InnerText element. Will retry next week.