Access denied error ( Visual Studio and WatiN )

后端 未结 3 1365
小蘑菇
小蘑菇 2021-01-06 15:00

I\'m using the WatiN testing tool with Visual Studio 2005. When I try to select a value from my list box I am getting an \"access denied\" error.

3条回答
  •  日久生厌
    2021-01-06 15:33

    This is a bug in the select list where if the list is not ready to accept input, and it can throw one several exception types. We solve it like this:

    try
    {
        _domContainer.SelectList(_control.WatinAttribute).Focus();
        _domContainer.SelectList(_control.WatinAttribute).Select(value);
    }
    
    catch (Exception e)
    { 
        Console.WriteLine("Select list eception caught: " + e.Message + e.StackTrace);
    
        // we have tried once already and failed, so let's wait for half a second
        System.Threading.Thread.Sleep(500);
        _domContainer.SelectList(_control.WatinAttribute).Select(value);
    }
    

    And yes I know that swallowing all exceptions like this is normally bad, but if the exception occurs again, it is thrown to the test code and the test fails.

提交回复
热议问题