Clicking on a OptionTag invalidates parent SelectTag
Posted: Sun Jul 25, 2010 11:49 am
Hi Team,
I am trying to loop through all the OptionTag elements in a SelectTag (a drop down menu).
I can loop through all the values but it seems that as soon as I click on an option tag, (which refreshes part of the web page), the Select Tag menu becomes invalid. I can no longer click on it. I have checked the 'valid' property and sure enough - after clicking on the child option tag, the SelectTag becomes invalid. This is despite the fact that the RanorexPath has not changed. I have confirmed this with Ranorex spy.
Code as follows:
SelectTag _stVenues = "/dom[@caption~'Venue Page']//form/select[@id='sltc']";
foreach (OptionTag _otVenue in _stVenues.Find<OptionTag>("./option"))
{
// Expand Menu
_stVenues.Click();
// Click on current item
ListItem _option = "/container[@caption='selectbox']/listitem[@accessiblename='" + _otVenue.InnerText + "']";
txtMessage.Text = "Current option item is: " + _otVenue.InnerText + "; Select Tag is: " + (_stVenues.Valid ? "VALID" : "NOT VALID"); txtMessage.Refresh();
_option.Click(); // Navigates to a new URL (refreshes the lowerhalf of web page)
Ranorex.Core.Delay.Seconds(2);
// !no longer valid - next iteration of loop will fail
txtMessage.Text = "Current option item is: " + _otVenue.InnerText + "; Select Tag is: " + (_stVenues.Valid ? "VALID" : "NOT VALID"); txtMessage.Refresh();
}
I seem to have reacquire the SelectTag to make it valid again by executing;
SelectTag _tmp_stVenues = "<same selectTag path>";
(Of course my loop object is still invalid)
1. Any suggestions to stop the object begin invalidated
2. Clicking on each item goes to a new URL which refreshes the lower half of the web page. Is it possible to find the URLs so I can navigate to them in turn without having to click on each item?
Thanks for your help?
Mark
I am trying to loop through all the OptionTag elements in a SelectTag (a drop down menu).
I can loop through all the values but it seems that as soon as I click on an option tag, (which refreshes part of the web page), the Select Tag menu becomes invalid. I can no longer click on it. I have checked the 'valid' property and sure enough - after clicking on the child option tag, the SelectTag becomes invalid. This is despite the fact that the RanorexPath has not changed. I have confirmed this with Ranorex spy.
Code as follows:
SelectTag _stVenues = "/dom[@caption~'Venue Page']//form/select[@id='sltc']";
foreach (OptionTag _otVenue in _stVenues.Find<OptionTag>("./option"))
{
// Expand Menu
_stVenues.Click();
// Click on current item
ListItem _option = "/container[@caption='selectbox']/listitem[@accessiblename='" + _otVenue.InnerText + "']";
txtMessage.Text = "Current option item is: " + _otVenue.InnerText + "; Select Tag is: " + (_stVenues.Valid ? "VALID" : "NOT VALID"); txtMessage.Refresh();
_option.Click(); // Navigates to a new URL (refreshes the lowerhalf of web page)
Ranorex.Core.Delay.Seconds(2);
// !no longer valid - next iteration of loop will fail
txtMessage.Text = "Current option item is: " + _otVenue.InnerText + "; Select Tag is: " + (_stVenues.Valid ? "VALID" : "NOT VALID"); txtMessage.Refresh();
}
I seem to have reacquire the SelectTag to make it valid again by executing;
SelectTag _tmp_stVenues = "<same selectTag path>";
(Of course my loop object is still invalid)
1. Any suggestions to stop the object begin invalidated
2. Clicking on each item goes to a new URL which refreshes the lower half of the web page. Is it possible to find the URLs so I can navigate to them in turn without having to click on each item?
Thanks for your help?
Mark