dynamic grid

4 posts, 0 answers
  1. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 11 Feb 2013 Link to this post

    Using http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/html/dynamic-grid.aspx i tried to automate a grid with code

    HtmlTableRow containerRow =

     

    null;

     

    foreach

     

     

    (HtmlTableRow r in Pages.EndpointClinicalPulse.LandingPageTable.AllRows)

     

    {

     

     

    foreach(HtmlTableCell c in r.Cells)

     

    {

    Log.WriteLine(

     

    "Cell Found.TextContent:"+c.InnerText);

     

     

     

    if(c.InnerText.Equals("Messaging_Test_Study"))

     

    {

    containerRow = c.Parent<HtmlTableRow>();

    }

    }

    }

    HtmlTableCell cbutton = containerRow.Cells[

     

    6];

     

    Log.WriteLine(cbutton.InnerText);

    cbutton.ScrollToVisible();

    cbutton.Click();

    Issue is...cells[6] is in another table. Grid is like as shown

    A B C D E F button
    A1 B1 C1 D1 E1 F1 button
    A2 B2 C2 D2 E2 F2 button

    above is a grid which contains a table. Also "button" is further in another table

     

     

    I am able to read the content of cells[6](ie text "button" is getting printed in log) but unable to click the button in cells[6]

     

  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 13 Feb 2013 Link to this post

    Hi Tanu,

    Try using a real mouse click instead:
    cbutton.MouseClick();

    If this doesn't work, try to find the 'button' in the cell. Here's a sample code:
    var button = cbutton.Find.AllByTagName("button").FirstOrDefault().As<HtmlControl>();
    button.MouseClick();

    Please try the suggestions above and let me know if this helps.

    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Tanu
    Tanu avatar
    2 posts
    Member since:
    Jan 2013

    Posted 14 Feb 2013 Link to this post

    Hi Plamen,

    Real mouse click is not working. Also getting the following error on using the second option

    Failure Information: ~~~~~~~~~~~~~~~Exception thrown executing coded step: '[WebTest_CodedStep] : New Coded Step'.InnerException:System.NullReferenceException: Object reference not set to an instance of an object. at TestProject3.WebTest.WebTest_CodedStep() in c:\Users\Tanu\Documents\Test Studio Projects\TestProject3\WebTest.tstest.cs:line 95------------------------------------------------------------'2/14/2013 1:34:21 PM' - Detected a failure. Step is marked 'ContinueOnFailure=False' aborting test execution.

  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 14 Feb 2013 Link to this post

    Hi Tanu,

    Unfortunately to be able to help you further with this problem a local reproduction is needed. Please provide us with a copy of your test and access to your application. If it is not possible to grant us access to your application, please take a Fiddler trace using FiddlerCap and send it to us in a zip file. If you deem that information too sensitive for this forum, you can create a support ticket and attach it there. Thanks for providing the information we need to best assist you.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top