Cannot access a disposed object. Object name: 'HtmlOptionElement' Error
I am automating a web app where I have a form of 3 filters to apply before searching for records obtained after selecting values in filter. I am navigating to the web page in application and applying 3 filters one by one. While most of the times they work fine, I get an exception "Cannot access a disposed object. Object name: 'HtmlOptionElement' " 1 in 50 times and the automation fails there throwing this exception. Can anybody know why this is occurring and a potential solution to it?
In many cases when you do a selection, web pages will replot part of the screen. This requires you to wait for the destroyed event and then wait for the created event before proceeding. Search in the RuntimeLog for "Control is matched" (that is created) and "Control is detached" (that is destroyed). After you perform a selection are you seeing that some of your controls are destroyed? This is often the issue.
When something works sometimes and then doesn't work other times, it is usually a timing issue. In your case, based on how fast your code executes or the system is currently performing, it will work sometime.
Thanks a lot for the valuable input Jeff. Can you please have a look at the part of my code attached in this reply and tell me if it is the right approach to use WaitForCreate of these selecting handles rather than checking IsDisposed every time before selecting values?