Access denied error ( Visual Studio and WatiN )

后端 未结 3 1361
小蘑菇
小蘑菇 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:16

    I have seen this a lot with select lists recently when using the WatiN 2.0 beta. Instead of using the aSelectList.Select(strText) option, it seems to work better when you do this:

    ie.SelectList(Find.ById("MySelect")).Option(Find.ByText("Option 1")).Select();
    

    This can also happen when changing an ASP.NET control that cause an auto-postback. The first change will register, but the next element you try to access will throw an "Access Denied" error because it is still trying to access the old page. In this case you can try using ie.WaitForComplete(), but sometimes this is required:

    ie.SelectList(Find.ById("AutoPostBackSelect")).Option(Find.ByText("Option")).Select();
    System.Threading.Thread.Sleep(200); //Sleep to make sure post back registers
    ie.WaitForComplete();
    ie.SelectList(Find.ById("MySelect")).Refresh()
    ie.SelectList(Find.ById("MySelect")).Option(Find.ByText("Option 1")).Select();
    

提交回复
热议问题