compare html table cell date and time with textbox date and time

4 posts, 0 answers
  1. Siva
    Siva avatar
    28 posts
    Member since:
    Apr 2012

    Posted 01 Oct 2012 Link to this post

    Hi

      I have a Issue with comparing the datetime html table cell with the textbox date time

    here is my code to store the textbox date time in to string varible

    string S_Time;
    S_Time = Pages.HttpLocalhostxxx.StartTimeInputText.Text.ToString()

    S_Time Has the Value = 10/1/2012 2:36:00 PM
    my table is

    NAme   Field1 Field2 Field3 Begin End TimeZone
    Actions
    Test   pro
      Filed2  
    Product 10/1/2012 2:36:00 PM 10/1/2012 5:34:00 PM (UTC-05:00) Eastern Time (US & Canada) Y

    I want to compare S_time with the HtmlTable cell Begin
    My Code is

     HtmlTable table = Find.ByExpression<HtmlTable>("TagIndex=table:0", "TagName=tabl
     HtmlTableRow row = table.Find.ByExpression<HtmlTableRow>("innertext=~Test", "tagname=tr");
     Assert.IsNotNull(row, "Site Didnot Exists");
     HtmlTableCell cell1 = row.Cells[4];


    How to compare cell1 with the variable S_Time






  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 02 Oct 2012 Link to this post

    Hello Siva,

    You can compare the value of the string variable 'S_time' to the inner text of the cell using the following code:
    Assert.AreEqual(S_time, cell1.InnerText);


    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Siva
    Siva avatar
    28 posts
    Member since:
    Apr 2012

    Posted 10 Oct 2012 Link to this post

    Hello Plamen

      Thanks for Your Reply.

    I have another question, If My First Column Data is Empty, and still need to find the row with the next availble Data (example with Field1 data "Pro"
    my table is

    NAme   Field1 Field2 Field3 Begin End TimeZone
    Actions

      pro
      Filed2  
    Product 10/1/2012 2:36:00 PM 10/1/2012 5:34:00 PM (UTC-05:00) Eas

    If My NAme Column Empty , How to find the Row by using Next Avilable field and then Compare that with Begin Cell Value with S_Time

    HtmlTableRow row = table.Find.ByExpression<HtmlTableRow>("innertext=~Pro", "tagname=tr"); is not working

    Thanks
    Regards
    Siva
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 15 Oct 2012 Link to this post

    Hi Siva,

    Try the following code:
    foreach (HtmlTableRow row in table.Rows)
    {
        if (row.Cells[1].InnerText == "pro")
        {
            Assert.AreEqual(S_Time, row.Cells[4].InnerText);
        }
    }

    If you continue to have difficulty, please provide access to your application or at least send us the HTML for that table and I'll gladly assist you in writing the code. If you can grant us access to your app but feel that information is sensitive, you can submit a support ticket which is confidential, unlike this forum.

    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!