Forum Discussion

BigDuy01's avatar
BigDuy01
New Contributor
9 years ago

search for text (span) on webpage

I'm trying to search for 

 

<span class="error-server-side" >

 

I tried using 

 

obj = page["NativeWebObject"]["Find"]("contentText", "*error-server*");

 

but it never finds it.  

 

I tried using the example from the help page below but it doesn't work.

 

https://support.smartbear.com/viewarticle/82834/

 

Any help would be great.  If you have any questions, please let me know.

  • Hi,

     

    First of all "error-server-side" is not the value of the contentText property, it's a name of the class.

     

    If you want to find this element, use:

    page.Find("className", "*error-server*", 10); /* 10 - is the value of the depth 
    for searching the element
    in the object's tree */

     

    More about the Find() method >>

  • Works for me.  Try experimenting only with Find() and strip out everything else.

     

    function Test2()
    {
      var browser;
      var page;
      var obj;
      Browsers["Item"](btFirefox)["Navigate"]("https://community.smartbear.com/nwkab66374/attachments/nwkab66374/Functional_Web_Testing/28191/1/test.html");
      browser = Sys["Browser"]();
      page = browser["Page"]("https://community.smartbear.com/nwkab66374/attachments/nwkab66374/Functional_Web_Testing/28191/1/test.html");
      obj = page["Find"]("className", "*error-server*", 10);
      Log["Message"](obj["Exists"]);
    }
  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    First of all "error-server-side" is not the value of the contentText property, it's a name of the class.

     

    If you want to find this element, use:

    page.Find("className", "*error-server*", 10); /* 10 - is the value of the depth 
    for searching the element
    in the object's tree */

     

    More about the Find() method >>

    • BigDuy01's avatar
      BigDuy01
      New Contributor

      I tried and it's still didn't work.  Please see that attachments.  1 is of the html page i'm trying to get it to find and the other one is the code.

       

      Thanks for helping!!!

      • joseph_michaud's avatar
        joseph_michaud
        Moderator

        Works for me.  Try experimenting only with Find() and strip out everything else.

         

        function Test2()
        {
          var browser;
          var page;
          var obj;
          Browsers["Item"](btFirefox)["Navigate"]("https://community.smartbear.com/nwkab66374/attachments/nwkab66374/Functional_Web_Testing/28191/1/test.html");
          browser = Sys["Browser"]();
          page = browser["Page"]("https://community.smartbear.com/nwkab66374/attachments/nwkab66374/Functional_Web_Testing/28191/1/test.html");
          obj = page["Find"]("className", "*error-server*", 10);
          Log["Message"](obj["Exists"]);
        }