Forum Discussion

josette_merhy12's avatar
josette_merhy12
Occasional Contributor
12 years ago

Input of type hidden not found in Script.

i have the following element:

<div>

<input type="hidden" data-u-id="numberOfSeats" name="NumberOfSeats" required="required"><span class="atom_validation_bsy required" style="">Required field</span></div>





i m trying to find the input element of type hidden, but it is found in script using the page.Find Method or page.NativeWebObject.Find mnethod using property name of value NumberOfSeats.



can anyone help me please???

  • Hi Josette,


     


    I guess you are using the Tree model in your project, right? This model doesn't show hidden elements in the object structure. So, it's impossible to call the methods you used to get the object. You need to use the EvaluateXPath or FindChildByXPath method to find elements by the values of the element’s attributes on the HTML page.


    For example:




      var page = //obtain the page


     


      // Call the function


      var tmp = page.EvaluateXPath("//INPUT[@name='NumberOfSeats']");


     


      // Check the result 


      if (tmp != null)


      {


        // If the element was found, convert the array to the JScript-compatible format


        var arr = (new VBArray(tmp)).toArray();


        // do what you want with the element


        


      }


      else


      { 


        Log.Error("The element was not found.");


      }





  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Josette,


     


    I guess you are using the Tree model in your project, right? This model doesn't show hidden elements in the object structure. So, it's impossible to call the methods you used to get the object. You need to use the EvaluateXPath or FindChildByXPath method to find elements by the values of the element’s attributes on the HTML page.


    For example:




      var page = //obtain the page


     


      // Call the function


      var tmp = page.EvaluateXPath("//INPUT[@name='NumberOfSeats']");


     


      // Check the result 


      if (tmp != null)


      {


        // If the element was found, convert the array to the JScript-compatible format


        var arr = (new VBArray(tmp)).toArray();


        // do what you want with the element


        


      }


      else


      { 


        Log.Error("The element was not found.");


      }