This is a migrated thread and some comments may be shown as answers.

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

3 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Siva
Top achievements
Rank 1
Siva asked on 01 Oct 2012, 07:20 PM
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






3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 02 Oct 2012, 07:29 AM
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
0
Siva
Top achievements
Rank 1
answered on 10 Oct 2012, 07:39 PM
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
0
Plamen
Telerik team
answered on 15 Oct 2012, 02:04 PM
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
Tags
General Discussions
Asked by
Siva
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Siva
Top achievements
Rank 1
Share this question
or