Cannot perform 'Click' on the hidden contr

2020-07-24 16:00发布

I've claim Id textbox, if claim id is duplicate,claim found link appears below claim id textbox. When clicked on this link it shows existing claim details. I need to test this click event and popup.

 public HtmlHyperlink UIClaimFoundHyperlink
 {
     get
     {
         if ((this.mClaimFoundHyperlink == null))
         {
             this.mClaimFoundHyperlink = new HtmlHyperlink(this);
             #region Search Criteria
             this.mClaimFoundHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Id] = "aClaimLink";
             this.mClaimFoundHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Name] = null;
             this.mClaimFoundHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Target] = null;
             this.mClaimFoundHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Claim Found";
             this.mClaimFoundHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Title] = null;
             this.mClaimFoundHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Class] = "listTblData-hotlink-noalign";
             #endregion
         }
         return this.mClaimFoundHyperlink;
     }
 }

if (claimFound_Hyperlink.Exists)
{
   Mouse.Click(claimFound_Hyperlink);
}

but it's throwing Cannot perform 'Click' on the hidden control.

I tried existing solutions but not working for me. I can see the control on UI.

I see exceptions on 'alt' 'type' 'value attribute'

ex--> 'claimFound_Hyperlink.Alt' threw an exception of type 'System.NotSupportedException'

Could this be problem ?

Please help.

2条回答
迷人小祖宗
2楼-- · 2020-07-24 16:11

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.

查看更多
爷、活的狠高调
3楼-- · 2020-07-24 16:15

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.

查看更多
登录 后发表回答