Can't acces hyperlink directly in a cell

Jan 23, 2014 at 9:01 AM
Hello,

I have vs 2013 with agent 2013 and the last Cuite Dll.

I have problem when i want to click in a link in a Cell.

Here is the code of the cell (there is header):
<td class="no-click">
  <a data-action="details" href="/link">Détails</a>
</td>
Previously, i used this code to click on the link and it worked perfectly:
public CUITe_HtmlTable tblDemandes = new CUITe_HtmlTable("Id=idTable");
tblDemandes.GetCell(iRow, iColumn).Get<CUITe_HtmlHyperlink>().Click();
Now when i run this, i have the following error:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: 
TechnologyName:  'Web'
ControlType:  'Hyperlink'
TagName:  'A'
 Failed to find any control that matched the search condition ControlType='Hyperlink' ---> System.Runtime.InteropServices
So i found code to bypass this error but i prefer the first one, so, why the first one doesn't work anymore?
public CUITe_HtmlTable tblDemandes = new CUITe_HtmlTable("Id=idTable");
tblDemandes.GetCell(iRow, iColumn).GetChildren()[0].Click();
Coordinator
Jan 23, 2014 at 1:05 PM
Hi fun_fabien,

I am not able to reproduce the issue.

Make sure you are using the correct zero-based index for the row and column.

Here is a sample test that works for me:
        [TestMethod]
        public void Click_OnHtmlHyperlink_WithDataActionAttribute_Succeeds()
        {
            // Arrange
            using (TempFile tempFile = new TempFile(
@"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table id=""tableId"">
            <tr id=""row"">
                <td class=""no-click"">
                  <a data-action=""details"" href=""/link"">Détails</a>
                </td>
            </tr>
        </table>
    </body>
</html>"))
            {
                CUITe_BrowserWindow.Launch(tempFile.FilePath);
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");

                CUITe_HtmlTable table = window.Get<CUITe_HtmlTable>("Id=tableId");

                CUITe_HtmlHyperlink hyperlink = table.GetCell(0, 0).Get<CUITe_HtmlHyperlink>();

                // Act
                hyperlink.Click();

                // TODO: Assert
                window.Close();
            }
        }
Jan 24, 2014 at 11:19 AM
Hello,

As i said, when i use: tblDemandes.GetCell(iRow, iColumn).GetChildren()[0].Click();
It's click on the link détails, so i'm sure that i'm using the correct zero-based index for the row and column.

i used dll version 12.0.0.0 and in my app.config, i redirect to correct assembly (if not, i have build compilation error).
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.CodedUITestFramework" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.TestTools.UITest.Common" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.TestTools.UITest.Extension" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.TestTools.UITesting" publicKeyToken="b03f5f7f11d50a3a"/>
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
So do you know if Microsoft.VisualStudio.TestTools.UITest.Extension and Microsoft.VisualStudio.TestTools.UITest.UITesting are really different between version 11 and 12?
Jan 30, 2014 at 10:47 AM
Edited Jan 30, 2014 at 11:18 AM
Hello, so after many test here is few example with error.

Your example works for me too
but this one doesn't work:
[TestMethod]
        public void Click_OnHtmlHyperlink_WithDataActionAttribute_Succeeds()
        {
            // Arrange
            using (TempFile tempFile = new TempFile(
@"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table id=""tableId"">
            <tr id=""row"">
                <td></td>
                <td class=""no-click""><a data-action=""details"" href=""/link"">Détails</a></td>
            </tr>
        </table>
    </body>
</html>"))
            {
                CUITe_BrowserWindow.Launch(tempFile.FilePath);
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");
                CUITe_HtmlTable table = window.Get<CUITe_HtmlTable>("Id=tableId");
                CUITe_HtmlHyperlink hyperlink = table.GetCell(0, 1).Get<CUITe_HtmlHyperlink>();
                // Act
                hyperlink.Click();
                // TODO: Assert
                window.Close();
            }
        }
And if we duplicate <td class=""no-click""><a data-action=""details"" href=""/link"">Détails</a></td> instead of an empty colum, so the click is on the first column instead of the second

Nb: i have same problem with Get<CUITe_HtmlImage>()
Coordinator
Feb 2, 2014 at 8:33 AM
Edited Feb 2, 2014 at 8:34 AM
Hi fun_fabien,

Thank you for providing a reproducible test method - it helped a lot! :)

I just checked in a fix for this issue: Changeset 32090
removed adding SearchConfiguration.AlwaysSearch to SearchConfigurations when wrapping a control to fix issue encountered in discussion 522298
added support for .net 4 for Visual Studio 2013 (but without silverlight support)

You will have to get the latest source code, build it, and reference the generated CUITe.dll.

Let me know if you encounter any other issues.

Thank you.
Feb 3, 2014 at 8:43 AM
Edited Feb 3, 2014 at 8:48 AM
Hello,

Thank you for your check in, it works for me.

but i still have error, if there is an image under the link, here is an example doesn't work for me:
error message is "UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control"
[TestMethod]
        public void Click_OnHtmlHyperlink_WithDataActionAttribute_Succeeds()
        {
            // Arrange
            using (TempFile tempFile = new TempFile(
@"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table id=""tableId"">
            <tr id=""row"">
                <td class="no-click">test
                </td> 
                <td class="no-click">
                    <a title="details" id="details" class="action-details" href="/link">
                        <img src="/test.png" />
                    </a>
                </td> 
            </tr>
        </table>
    </body>
</html>"))
            {
                CUITe_BrowserWindow.Launch(tempFile.FilePath);
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");
                CUITe_HtmlTable table = window.Get<CUITe_HtmlTable>("Id=tableId");
                CUITe_HtmlHyperlink hyperlink = table.GetCell(0, 1).Get<CUITe_HtmlHyperlink>();
                // Act
                hyperlink.Click();
                // TODO: Assert
                window.Close();
            }
        }
I will create other thread for other errors i had