question

bmcmanus avatar image
bmcmanus asked bmcmanus answered

Using Form Maps to Protect against Changing Index IDs

We are doing web portal testing and feature Edit buttons on the page have an id depending on what alphabetical position they show up on the page (:xpath=(//input[@value='Edit'])[14];). If a features is added that preceeds an existing feature alphabetically, the id of the button will increment (i.e. :xpath=(//input[@value='Edit'])[15]). Can I use a general form map for the page that assigns an alias for each button and reference the alias in my test case so that if a feature is added I can change the aliases in the form map and not in every line they are referenced in the scripts? Is there a better way?
iTestform maps
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JeffJ avatar image
JeffJ answered
You need another condition in the query. What should work is: //INPUT[@value="Edit" and contains(@onclick,"{0}")] If you use the "contains" function, you can look at the text in the "onclick" and determine exactly which edit button you want to click. This eliminates the need for the numerical index which will provide you with the ability to click the correct button regardless of how many you have in the list and where you're button winds up. Also noticed I did not put the text here. When you call the function, provide it with the string to get to any of the edit buttons. In your case, you'd use "Selective Call Acceptance". Let me know if this works for you!!
1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bmcmanus avatar image bmcmanus commented ·
I defined a custom target in the Form Map called Advanced_Features with the following query: :xpath=//input[@value='Edit' and contains(@onclick,"{0}")]. I did not define any arguments in the form map but used Advanced_Features("Selective Call Acceptance") as the target in the test case. iTest could not find that target. Is that what you intended for me to do?
0 Likes 0 ·
JeffJ avatar image
JeffJ answered
To answer you question, this is exactly the purpose of the form maps. From your example, it looks like you're looking for the 15th edit button so I'll assume there's a table of information where each row has a edit button. If this is the case, you can open up your XPATH query to find the row where a certain value exists and then click the input on that row. It would look something like: //TABLE/TR[TD="MyFeature"]/input[@value="Edit"] This would click the edit button for the row that has the particular value I'm looking for. This should be thought of as an example as we don't know exactly what your HTML looks like. If you'd like a more specific example, you can either email or post the form map and I'll try to be more exact.
1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bmcmanus avatar image bmcmanus commented ·
Thanks Jeff - I attached the testcase and form map. I did not find the table you thought I should. My Selenium capture uses an "Edit" index and the form map html is in a format that the web session could not replay (worked with your support team to verify this). Anyway, I created a target for "Selective_Call_Acceptance-Edit" as a first step and tried to reference the xpath command that Selenium generated in my testcase right after the snapshot but to no avail. [Thoughts?][1] [1]: /storage/temp/3801-4144761.fftc
0 Likes 0 ·
4144761.fftc (149.8 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.