Forum Discussion

tdemarco's avatar
12 years ago

Find or FindChild within a section of my page

Hello,

I'm trying to find an object in my webpage without using Name Mapping.  I have used page.NativeObject.Find several times already and love it.  But now I can't apply it find what I need, and I don't want to relay on Name Mapping.  I am using JScript.

My code is as follow:

This one, finds the section where I want to find my object:

mySection = page.NativeWebObject.Find("contentText","I don't have time to work out*","div");

if (mySection.Exists)

Log.Message("found it: " + mySection.outerHTML);

else

Log.Message("NOT found");



This returns the section I'm looking for.  I have this result (html code) in a txt file, but I wasn't able to attach it to this thread.  When I click on upload, it says that this type of file can't be uploaded.

Anyway, then I want to find another element within this section, and I do:

propertyNames = new Array("name", "value", "type");

propertyValues = new Array("surn:symphony:Get*", "50", "radio");

mySlider = mySection.FindChild(propertyNames,propertyValues,2000);

if (mySlider.Exists)

Log.Message("found mySlider: ");

else

Log.Message("did NOT find mySlider");



I tried Find and FindChild, but I can't figure out how to find it.

Within "mySection" there are 5 elements that have the same name and type, but only one which "value" is "50".




This is the content of "mySection":

<div id="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" class="ractives-component ractives-slider-component">

 <div class="row section-row">

  <div class="span2">&nbsp;</div>

  <div class="span6">

   <div class="slider">

    <p class="title">I don't have time to work out.</p>

    <div class="slider-box clearfix relative">

     <div class="slider-rail relative"></div>

     <div class="slider-options clearfix relative">

      <label style="width: 25%; margin-left: -12.5%;" class="input-label radio-label label-on first">

       <input tabIndex="1" name="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" value="0" type="radio" validate="">

        <span class="icon"></span>

        <span class="title ">Strongly disagree</span>

        <div class="error-message"></div>

      </label>

      <label style="width: 25%;" class="input-label radio-label">

       <input tabIndex="1" name="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" value="25" type="radio" validate="">

        <span class="icon"></span>

        <div class="error-message"></div>

      </label>

      <label style="width: 25%;" class="input-label radio-label">

       <input tabIndex="1" name="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" value="50" type="radio" validate="">

        <span class="icon"></span>

        <div class="error-message"></div>

      </label>

      <label style="width: 25%;" class="input-label radio-label">

       <input tabIndex="1" name="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" value="75" type="radio" validate="">

       <span class="icon"></span>

       <div class="error-message"></div>

      </label>

      <label style="width: 25%; right: -12.5%; position: absolute;" class="input-label radio-label last">

       <input tabIndex="1" name="surn:symphony:Get Active:Personalization:Stage 1:Get Active 1 1:SLIDER[1]" value="100" type="radio" validate="">

       <span class="icon"></span>

       <span class="title ">Strongly agree</span>

       <div class="error-message"></div>

      </label>

     </div>

    </div>

   </div>

  </div>

  <div class="span2">&nbsp;</div>

 </div>

</div> 



Thank you,


  • Hi 

    When I was using find the other day i found it was case sensitive. 



    propertyNames = new Array("name", "value", "type");



    Try:




    propertyNames = new Array("Name", "value", "type");
  • TestComplete's FindChild method searches by object properties that are displayed in Object Browser, so when you add Name property it will the name of TestComplete object, but not the native web object's name. Try to simply remove the name property and its value from the arrays and it should work because there are no other radios in your code.