Menu

nested table

Help
2005-01-25
2013-04-26
  • Marc Schmidt

    Marc Schmidt - 2005-01-25

    Hello All,

    I am a newbie in java and thats why I have a little problem to get one thing done... to get a cell of a nested table.

    Situation, what I use:
    Java, Eclipse, JUnit, HttpUnit, HTML nested Table.

    I have a nested table and I would like to read a specific word (here: Word 2 1) with a script for an assert.

    The Table:

    <table>
    <tr>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td></td>
      <td>
       <table>
        <tr>
         <td>Word 1 1</td>
         <td>Word 1 2</td>
        </tr>
        <tr>
         <td>Word 2 1</td>
         <td>Word 2 2</td>
        </tr>
       </table>
      </td>
    </tr>
    </table>

    For an another (non nested) table this works:

    WebConnection wc     = new WebConnection();
    WebResponse response = wc.getResponse("http://www.example.com/login.php";);
    WebRequest request   = response.getRequest("SubmitButtonID");
    request.setParameter("username", "testuser");
    request.setParameter("password", "12345678");
    response        = wc.getResponse(request);
    WebTable wt     = response.getTables()[0];

    assertEquals( " [HttpUnitTest.test()] cell 0,0", "Word 2 1", _table.getCellAsText(0,0));

    The documentary says:
    The : getTables()  method will return an array of the top-level tables in the page (that is, those which are not nested within other tables), in the order in which they appear in the document.

    Do I have a chance to get a specific word of a cell in a nested table?

    This is what Id like to do with it:

    assertEquals( " [HttpUnitTest.test()] cell 0,0", "Word 2 1", _table.getCellAsText(0,0));

    (In my case the nested table is in the first top-level table of the site)

    HttpUnit was a great help so far, thanx for working on it!

    Best wishes and thank you for reading this

    Marc. (Pixelhead)

     
    • Marc Schmidt

      Marc Schmidt - 2005-01-25

      An attachment to my question above:

      What I am looking for is to get in a nested table (of the second level table) all words / elements of a row of a (2nd level) table :

      WordInCell_1 WordInCell_2 WordInCell_3 ButtonInCell_4

      I want to click the ButtonInCell_4 that fits to the WordInCell_1. Thats why...

       
    • Marc Schmidt

      Marc Schmidt - 2005-02-09

      Its ok, this thread is fixed and done.

      I found out a solution to get the specific nested table, count the rows with a for statement and put together what belongs together;-)

      No answers to this thread are necessary anymore.

      Thanx

       

Log in to post a comment.

MongoDB Logo MongoDB