Cannot perform 'Click' on the hidden control

空扰寡人 提交于 2019-12-04 15:10:44
AdrianHHH

This can happen when the window is displayed a second time. To the eye the two windows are the same, but they are different. The first time the window appears and Coded UI accesses it, the property code shown above sets this.mClaimFoundHyperlink to refer to that window. When the window is displayed for a second time this.mClaimFoundHyperlink still refers to the first window, which is no longer available. Hence the exception.

Sometimes refreshing the property works. Try calling this.mClaimFoundHyperlink.Find().

See also this question about a similar problem.

I was facing a similar problem recently and the problem turned out to be that the UITestControl (an HtmlCell in my case) was invisible only when the browser window was Maximized. I used this code to Restore the window before trying to click:

BrowserWindow browser.Restored = true;

It might work for you too.

One other note, the screen resolution of the VM I was running the test in had to be a certain size for the Click action to work. I know that it's insane but I struggled with this for a week before getting it to work. Try increasing your screen resolution too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!