| |
When testing dynamic pages using SWEA the IsOptional property must be used. If the property is set to true it allows the Scene to be validated without that control being part of it.
The other day I automated a page that had 3 dynamic levels to it. In other words, when control 1 was present, control 2 and 3 were not; when 2 was present, 1 and 3 were not; when 3 was present, 1 and 2 were not. In order to successfully automate the page I had to toggle the IsOptional property on the fly. In the past I've used IsOptional as it was defined during my recording and present in my SWEA htp file, but I never had to modify the property in the middle of a test so that the Scene could successfully load. This is how I did it:
|
//Input a friendly name and submit the form ((HtmlInputText)(myBrowser.Scene["FriendlyName"])).Value = userID; ((HtmlInputButton)(myBrowser.Scene["FriendlyName"])).Click(); //Set the IsOptional property to false for the new control //that appears on the postback and the previous controls //that are no longer present to true ((HtmlAnchor)(myBrowser.Scene["lnkViewUserDetails"])).IsOptional=false; ((HtmlInputText)(myBrowser.Scene["FriendlyName"])).IsOptional=true ((HtmlInputButton)(myBrowser.Scene["FriendlyName"])).IsOptional=true //Wait for the Scene to load myBrowser.Scene.WaitForActive(30000); //For some reason if I don't run the RunIdentifcation() method //before I click the link a chained COM exception occurs. // So here I run the method myBrowser.ExplorerManager.RunIdentification(); //Now I can click the link ((HtmlAnchor)(myBrowser.Scene["lnkViewUserDetails"])).Click(); //Now the link is no longer part of the page so I set IsOptional //to true before I do anything with the new controls ((HtmlAnchor)(myBrowser.Scene["lnkViewUserDetails"])).IsOptional=true; myBrowser.ExplorerManager.RunIdentification(); | |
|