6 Replies Latest reply: Oct 22, 2013 8:13 AM by DavidC. RSS

    OATS - Playback not following link with nested SPAN

    DavidC.

      When a link is embedded within a span, and also contains a span, the playback

      will "click" the link, but not actually follow the link.

       

      For example :

       

      page 1:

      <html>

      <head>

      <title>Test page 1</title>

      </head>

      <body>

      <table border="0" cellspacing="5">

      <tr>

      <td><a href="test2.html">Normal Link</a></td>

      <td><span><a href="test2.html"><span><span><span><span>Link within a

      span</span></span></span></span></a></span></td>

      </tr>

      </body>

      </html>

       

       

      Page 2:

       

      <html>

      <head>

      <title>Test page 2</title>

      </head>

      <body>

      <table border="0" cellspacing="5">

      <tr>

      <td><a href="test.html">Normal Link</a></td>

      <td><span><a href="test.html"><span><span><span><span>Link within a

      span</span></span></span></span></a></span></td>

      </tr>

      </body>

      </html>

       

       

      test_link.java (replace the HOST with your hostname):

       

       

      public void run() throws Exception {

      beginStep("[1] Test page (/test.html)", 0);

      {

      web

      .window(28, "/web:window[@index='0' or @title='New Tab']")

      .navigate(

      "http://HOST/test.html");

      web.window(29, "/web:window[@index='0' or @title='Test page']")

      .waitForPage(null);

      {

      think(0.66);

      }

      web

      .link(

      30,

      "/web:window[@index='0' or @title='Test

      page']/web:document[@index='0']/web:a[@text='Normal Link' or

      @href='http://HOST/test2.html']")

      .click();

      }

      endStep();

      beginStep("[2] Test page 2 (/test2.html)", 0);

      {

      web.window(31, "/web:window[@index='0' or @title='Test page 2']")

      .waitForPage(null);

      {

      think(0.028);

      }

      web

      .element(

      32,

      "/web:window[@index='0' or @title='Test page

      2']/web:document[@index='0']/web:span[@text='Link within a span']")

      .click();

      }

      endStep();

      beginStep("[3] Test page (/test.html)", 0);

      {

      web.window(33, "/web:window[@index='0' or @title='Test page']")

      .waitForPage(null);

      {

      think(1.335);

      }

      web

      .link(

      34,

      "/web:window[@index='0' or @title='Test

      page']/web:document[@index='0']/web:a[@text='Normal Link' or

      @href='http://HOST/test2.html']")

      .click();

      }

      endStep();

       

      }

       

       

       

       

      Using the examples above, create a functional web application script that

      will click each links.

       

      you will see that the link embedded in spans will NOT be followed WHEN the

      "INDEX" isn't present in the script.

       

      I can't use the "INDEX" as it isn't reliable enough (it can change at any time, due to version or configuration changes in the application I am testing)

       

      I've found a similar issue here :

      Oracleats.com - Open script error: link is not getting clicked

       

       

      I've also posted a bugdb for this :

      https://bug.oraclecorp.com/pls/bug/webbug_print.showbug?c_rptno=17635276

        • 1. Re: OATS - Playback not following link with nested SPAN
          Deepu Muraleedharan


          Hi David,

           

          From my understanding, your script fails at

          web

          .element(

          32,

          "/web:window[@index='0' or @title='Test page

          2']/web:document[@index='0']/web:span[@text='Link within a span']")

          .click();

          }

           

          Trial and error:

          replace span with a

          and mention text of link in attribute value

          • 2. Re: OATS - Playback not following link with nested SPAN
            DavidC.

            I did managed to get the link to work after many trial and errors:

             

             

            web

            .element(

            32,

            "/web:window[@index='0' or @title='Test page

            2']/web:document[@index='0']/web:span[@text='Link within a span']").getChildren().get(0).click();

            }

             

            I am not sure this will cover every cases, but at least this one allowed me to get rid of the "INDEX".

            • 3. Re: OATS - Playback not following link with nested SPAN
              Deepu Muraleedharan

              DavidC. wrote:

               

              I did managed to get the link to work after many trial and errors:

               

               

              web

              .element(

              32,

              "/web:window[@index='0' or @title='Test page

              2']/web:document[@index='0']/web:span[@text='Link within a span']").getChildren().get(0).click();

              }

               

              I am not sure this will cover every cases, but at least this one allowed me to get rid of the "INDEX".

              This will select first child of span. You can find all children of span in DOMTree.

              My suggestion:

               

               

              List <DOMElement> list = web.element("/web:window[@index='0' or @title='Test      page2']/web:document[@index='0']/web:span[@text='Link within a span']").getElementsByTagName("A");

              list.get(0).click();


              This code will get only children with tag A, ie. link

              • 4. Re: OATS - Playback not following link with nested SPAN
                DavidC.

                Tried the solution you proposed above, but the code won't compile :

                 

                Multiple markers at this line

                  - DOMElement cannot be resolved to a type

                  - List cannot be resolved to a type

                 

                ---

                 

                I'm still fairly new a writing scripts for Openscript, so it might just be that I don't put this line at the correct place.

                • 5. Re: OATS - Playback not following link with nested SPAN
                  Deepu Muraleedharan

                  Add following import statements to the top of script

                   

                  import java.util.List;

                  import oracle.oats.scripting.modules.webdom.api.elements.DOMElement;


                  Also add suppress warning to run method

                   

                  @SuppressWarnings("unchecked") public void run() throws Exception{   .....  }

                  • 6. Re: OATS - Playback not following link with nested SPAN
                    DavidC.

                    ok, that worked, so the solution was :

                     

                     

                    Add following import statements to the top of script, in the import section

                     

                    import java.util.List;

                    import oracle.oats.scripting.modules.webdom.api.elements.DOMElement;


                    Also add suppress warning to run method

                     

                    @SuppressWarnings("unchecked") public void run() throws Exception{   .....  }

                     

                    Then, when I need to click a "link" within a span, access it in the following way :


                    List <DOMElement> list = web.element("/web:window[@index='0' or @title='Test page 2']/web:document[@index='0']/web:span[@text='Link within a span']").getElementsByTagName("A");

                    list.get(0).click();

                     

                     

                     

                    Thanks a lot for your help !