Inspect Web element


#1

Hi

I am using Katalon Studio for my web testing.I have observed that ID for Web element (Recorded by Katalon) keep on changing and it is creating lots of rework for us

Is there way that we can use Database field name mapped with HTML Web Element for locating web element?

Will we get database field name in DOM Structure when we inspect it?

Please guide appropriately

Thanks
Deelip


#2

If your ID is dynamic and keeps changing - just try editing the xpath to locate without using ID


#3

Hi

Thanks for your response

We are already optimizing our script to have custom xpath and not having dependency on ID but my question was, can not we use Database unique field name to locate web element on HTML Page as i am assuming there will be mapping between web element and DB field and it will be better to locale element with DB field which will be always unique

Thanks with Regards
Deelip


#4

You understand, we can’t answer that since we can’t see your HTML?

Please, follow this advice:


#5

Hi Russ

Thanks for your detailed response

I am new to Katalon and have started learning it

Let me try here to explain again what i wanted to know from the Katalon expert

Problem statement - The application which i am working on for automation is IBM product and observed that the sometime ID for web element changes and because of that scripts fails and once the automated scripts fails then we try to define custom unique xpath. there is possibility that xpath also changes and we have see such type of case as well

Information needed - is there way we can locate web element using database field name as my understanding is, web element will have one to one mapping with Database field.Database field name will be always unique and there will be no issue of changing it like it changes for web element ID, xpath, text etc?

Also, i would like to know whether Database field name will appear or not in DOM when we do “Inspect”?

Thanks
Deelip


#6

Let me assume you have a Database table like this:

name age address
Dung 18 Saigon
Alex 17 Los Angeles
Thanh 16 Taipei

Also let me assume your HTML has a portion like this:

<div id="team">
    <div class="person">
        <span data-dbColumn="name">Dung</span>
        <span data-dbColumn="age">18</span>
        <span data-dbColumn="address">Saigon</span>
    </div>
    ....
</div>

Then, you can write a Katalon Studio test case as this:

WebUI.openBrowser('')
WebUI.navigateToUrl('......')

def index = 0
def tObj = new TestObject()
tObj.addProperty('xpath', "//div[@id='team']/div[@class='person'][${index}]/span[@data-dbColumn='name']")
WebUI.verifyElementText(tObj, 'Dung', false)
...

The above HTML contains dbColumn attribute which is the mapping information between Database table column and HTML node. This would be a possible approach.

HTML allows you to add any attribute starting with data-:
https://www.w3schools.com/tags/att_global_data.asp


#7

Hi

thanks for the detailed explanation

i am pasting here the screen shot of HTML page and also DOM. in this screen shot i am inspecting Title field, in the DOM you can see the section pointing to “Title” field on HTML page. i am not sure which one in DOM is DB field name which is mapped with “Title” field on HTML page. can you guide me how to locate the DB field which is mapped with Title field

thanks
Deelip

image


#8

No, I can not because I do not know at all about your web app.

Please ask to the developer who developed the server-side application.