Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to capture dynamically changing element ids of a text box?
#1
Not Solved
Hi,
I am writing scripts for a web page, which has 7 edit boxes. The element id of each box is unique. The element ids are changing dynamically each time you invoke the page. I inspected the properties of the edit boxes using developer tool bar and below are the details:
Code:
EditBox1 : <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d91519e189" name="actuals_hours">
EditBox2: <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d91519e198" name="actuals_hours">
EditBox3: <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d91519e206" name="actuals_hours">
I cleared the caches of the page and again invoke the same page. Now I inspect the same edit boxes using Developer tool bar. Now the element ids of the pages have been changed. Below are the details:
Code:
EditBox1 : <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d96132e187" name="actuals_hours">
EditBox2: <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d96132e196" name="actuals_hours">
EditBox3: <input type="text" title="ETC: 6.40" alt="ETC: 6.40" class="formFieldNoWidth" maxlength="" size="4" value="" id="d96132e204" name="actuals_hours">
Can you please suggest , how can I write the script in such a way that even if the element id changes should not affect my script? I have been asked to write the script using element id only.
Regards,
Pinaki
Reply
#2
Not Solved
Hi,

Did you try using descriptive programming.

Regards,
Parminder
Reply
#3
Not Solved
Yes I tried. But the class name is same for all the boxes. Only the element ids are changing dynamically.
Can you provide any sample code ?
Reply
#4
Not Solved
Hi,

Please see if this solves your problem:

Code:
Set oDesc=Description.Create()
oDesc("micclass").value="WebEdit"
Set obj_coll=Browser().Page().ChildObjects(oDesc)
obj_Coll.item(0).Set "test1"
obj_Coll.item(1).Set "test2"

you can check in which edit box "test1" is entered and similarly you can enter values in all the 7 edit boxes just by changing the item number

Regards,
Parminder
Reply
#5
Not Solved
Forget about qtp for a while, how will we ourself recognize those edit boxes uniquely when the only property known itself keeps changing?
You will have to ensure uniqueness! ask the developers to give unique "name" to the text boxes or find out why the id is changing
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UFT issues with Outsystems dynamically generated Id/names jherron 2 1,122 03-02-2020, 09:33 PM
Last Post: Swishy70
  Unable to capture value of Webelement which is changing dynamically sheetal 9 15,634 02-16-2018, 11:01 AM
Last Post: janki_kakadia
  How can we get the Windows application Text box background color Using UFT 11.53 Kuppampattu 3 5,669 06-06-2017, 11:12 AM
Last Post: workrohit08
  Unable to click on dynamically changing webelement preeti 0 1,693 04-29-2017, 08:50 PM
Last Post: preeti
  Page element keep changing chong67 4 4,273 11-08-2016, 09:17 PM
Last Post: Paul Rammone

Forum Jump:


Users browsing this thread: 1 Guest(s)