开发者

Silverlight UI Automation issue - element cannot be found

开发者 https://www.devze.com 2023-02-28 23:22 出处:网络
I need to create automated tests for a Silverlight application, I use the System.Windows.Automation namespace. My problem is the following:

I need to create automated tests for a Silverlight application, I use the System.Windows.Automation namespace. My problem is the following:

I use AutomationElement.FindFirst to locate UI elements in the UI tree:

AutomationElement toBeInvoked = browser.FindFirst(TreeScope.Descendants,
                    new PropertyCondition(AutomationElement.AutomationIdProperty, id));

This works for a few steps, but after it won't find anything. I inspected that after screen changes the UI tree is going to be empty, UISpy sees only the Silverlight control, but nothing more: screenshot . (I've also tried to use TreeWalker, but the result was the same.) If I click manually, and inspect the elements with UISpy, everything is OK. But when I run my code, it stops (usually at the same button).

Later I realized that if I click through manually the screens that my code will visit, and after I run it, there won't be any issue... Stra开发者_StackOverflow中文版nge. I tried it in FF 3.6, 4.0 and IE8. The problem is the same in every browser.

Has anyone any idea what could be wrong, or where could be the mistake? Am I missed something in my code, or the problem is in the settings of the browser?

Thanks in advance, regards,

Miklos


"If I click manually, and inspect the elements with UISpy, everything is OK. But when I run my code, it stops"

You can simulate manual-click this trouble-causing button by: 1.Get the coordinate of the button you want click by UI Automation; 2.Drive your mouse to click on its coordinate(by win32 mouse_event api);

See that if its following steps can run or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消