Custom Control for <tr>

May 13, 2013 at 5:50 PM
I have a set of rows that I want to access, they will look like the following

<table>
<tr id="x">
<td>
 ... bunch of stuff here
</td>
</tr>
<tr id="z>
...
</tr>

The goal is to use each row to get the elements with it as each row has a similar set of data, so the idea is that this custom control can access that data.

I have this:
    /// <summary>
    /// Class for the Merchant Control (Div that surrounds all of the products and elements for earch merchant in the cart)
    /// </summary>
    public class CUITe_HtmlCartProductControl : CUITe_HtmlCustom
    {
        private const string _tagName = "tr";

        #region Constructors
        /// <summary>
        /// Default Constructor
        /// </summary>
        public CUITe_HtmlCartProductControl()
            : base(_tagName)
        {
        }

        /// <summary>
        /// Default Constructor for search properties
        /// </summary>
        /// <param name="searchProperties">The search properties</param>
        public CUITe_HtmlCartProductControl(string searchProperties)
            : base(_tagName,searchProperties)
        {
        }
        #endregion

        /// <summary>
        /// Gets the Delete Product Link
        /// </summary>
        public CUITe_HtmlHyperlink uiDeleteProductLink
        {
            get
            {
                return this.Get<CUITe_HtmlHyperlink>("Id~DeleteItem");
            }
        }
    }
But when I try to get it it fails
this.Get<CUITe_HtmlCartProductControl>("Id=x);

It says it can't find the element of HtmlCustom with tagname "tr" and id "x" ... so it seems like it can't find it even though the right data is there.

Any idea if there is something special about table rows and why table row isn't available as a default CUITe control (if it was i'd just inherit that in my class rather than do this custom thing)
Coordinator
May 14, 2013 at 8:00 AM
I've just checked in some code that fixes the issue with custom controls.

Commit 26882

See the "Launch_ObjectRepositoryTempHtmlFile_CanFindUnorderedListsByTagAndClassName" test method for sample code.

In regards to supporting HtmlRow, I've created a work item #1214.

Please let me know which methods you expect CUITe_HtmlRow to have.

Thank you.
May 14, 2013 at 12:44 PM
Thanks, I will give that a try.

I am not sure what methods to expect for something like that, it is just nice to have when tables are used for layouts so you can access a specific row as a top level parent. My custom control just defines the tagname and I don't need any additional functionality for that specific element, I'd be creating a custom control regardless whether a TR element exists or not, but instead of inherting the custom control object i'd be inheriting the table row object.

The only thing I could think of is if I got the "table" it would be nice if I could return the row or column objects as part of that class. I could see that being beneficial but once again not something that I necessarily need right now.
May 14, 2013 at 1:15 PM
I got the latest source build and copied over the DLL but I'm still having the same error. I was taking a look at the same code and I don't see anything that i'm doing differently other than defining my custom control as a class (so I can add more properties to it).

Test method TejariAutomation.Tests.Basket.BSK_070_VerifyBasketSettingsProductDeletedThenAddedBack threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Custom'
Id: '555002_GP2'
TagName: 'tr'
Failed to find any control that matched the search condition Id='555002_GP2' && ControlType='Custom' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
<table class="cart" cellspacing="0">
          <tbody>
            <tr id="555002_gp2">
...
            </tr>
          </tbody>
        </table>
Coordinator
May 15, 2013 at 8:40 AM
I've just checked in a fix in commit 26934 with the following test:
[TestMethod]
        public void GetHtmlRow_ById_Succeeds()
        {
            // Arrange
            using (TempFile tempFile = new TempFile(
@"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table class=""cart"" cellspacing=""0"">
          <tbody>
            <tr id=""555002_gp2"">
                <td>
                    banana
                </td>
            </tr>
          </tbody>
        </table>
    </body>
</html>"))
            {
                CUITe_BrowserWindow.Launch(tempFile.FilePath);
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");

                // Act
                CUITe_HtmlRow row = window.Get<CUITe_HtmlRow>("id=555002_gp2");

                // Assert
                Assert.IsTrue(row.Exists);

                window.Close();
            }
May 15, 2013 at 6:54 PM
That worked, thank you!