How to get html dynamic value


#1

Hi Katalon experts,

I’m pretty new using Katalon and I want to get the value from a class. When I spy the object from the web I get the below xpath value in attributes:

id(“block-company-website-account-menu”)/ul[@class=“menu”]/li[@class=“menu-item stock-ticker”]/div[@class=“stock-values”]/span[@class=“price”]

I want to get the value for class “price” that is changing daily.

Thanks and regards,
Ruben B


#2

By the looks of it you need…


#3

Hi Russ,

Thanks for your help! I already tried that and it works while the text is the same but it will fail tomorrow that the value changes.

Thanks,
Ruben B


#4

Let’s be clear about the terminology: “value” is not the same as “text”. With the limited amount of information you have provided, I think you’re looking for the text. If that is so and your xpath is correct, then the text (within the span element) whatever it is, will be returned by getText.

If that is not the case, then you’re not providing enough info. Read this and follow the advice.


#5

If get text is not working try using attribute to get text.

getText= WebUI. getAttribute ( findTestObject (‘TestObject/Details’), ‘value’)
System. err.println('Text is: ’ + getText)


#6

Hi Everybody,

Thanks for your help, you were right, it was gettext and i was able to get it.

Thanks,
Ruben B