FAQ: Why can’t I click on the hyperlink which contains an image?
I have the following construct in my html page.
<a href="https://bing.com"><img src="bing.jpg"/></a>
I am unable click on this hyperlink. Why?
In this case, the hyperlink does not have a clickable point. The image completely covers the hyperlink. You can click on the image though. In most applications, we find that click on the image is correct expected behavior.
Comments
Anonymous
May 03, 2010
Hi Mathew, I have an application in which menu is composed from HtmlHyperlink items. How can I check if an HtmlHyperlink item is visible? Because it may be hidden. Here is an example: Menu1 Submenu1 Menu2 Submenu2 If the user clicks on Submenu1, the Submenu2 item exists, but it's hidden. RegardsAnonymous
May 04, 2010
You can use the TryGetClickablePoint() method to verify if a control is clickable. We decided against using the term "Visible" since there was a lot of controversy around its definition.Anonymous
May 05, 2010
I've tried this, but I got an error: Test method TestManager.LogIn.CodedUITestMethod1 threw exception: Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnHiddenControlException: Cannot perform 'GetClickablePoint' on the hidden control.Anonymous
May 05, 2010
Did you use TryGetClickablePoint(). THis method catches the exception and returns true or false. If you use GetClickablePoint, the above exception will occur as expected.Anonymous
May 05, 2010
I've used a method: public bool linkExists(HtmlHyperlink link) { Point p; try { p = link.GetClickablePoint(); } catch (FailedToPerformActionOnHiddenControlException e) { return false; } return true; } But isn't there a direct way to check this? This works only with walk arround?Anonymous
May 05, 2010
The direct way is to use link.TryGetClickablePoint(). public bool linkExists(HtmlHyperlink link) { Point p; return link.TryGetClickablePoint(out p); }