Can Katalon Test SAP HTML with FRAMESETs? [was: How to extract value of a text field?]

Hello,

I am having trouble extracting value from a text box. I am using the getAttribute method but still, it returns a ‘Null’ value.

Here is my code:

String sLeadID_Accept = WebUI.getAttribute(findTestObject('Object Repository/Harmony_OR/Page_finally/span_201481040'), 'value')

WebUI.comment("Lead ID is: $sLeadID_Accept")

Here is the error I get after executing it:
Lead ID is: null

I am trying to capture the highlighted ID in the screenshot below:

the id highlighted in red (below screenshot) is what I am trying to capture:

Thanks,
Saumil

hello,
question: that number is only in that title?
to get that, use getText() and then parse it
otherwise, please share html snipplet of that field you are trying to get value from…

1 Like

Hello, not sure whether you can access the link, but here it is:
view-source:https://ict.wdf.sap.corp/sap(ZT1sV2VXbWh3WWprSWxLckF1UV9Ma0p3PT1DSlR2SV9pNUh0eXR0WGExeDlVRUxBPT0=)/bc/bsp/sap/crm_ui_frame/BSPWDApplication.do?sap-client=001&sap-language=EN&sap-domainrelax=min&sap-domainrelax=min

sorry, our corpo-proxy is quite strict
image

Change the above statement to:
WebUI.comment("Lead ID is: ${sLeadID_Accept}") // notice the curly parenthesis
or
WebUI.comment("Lead ID is: " + sLeadID_Accept)

For some reason, I am not able to see how the id 201481050 is stored in the HTML.

Not sure whether the screenshot will be useful but that’s what I see when I inspect it at my end.

Unfortunately it’s not working. Getting Lead value is the problem here

It’s useless.

Let’s be clear, Inspect in this context is a reference to the browser’s Inspect function offered by the right-click menu on a web page.

I don’t believe that Inspecting an element on a web page the browser chooses to show you an element (<title> in this case) which is found inside the <head> element which contains nothing visible on the page.

So, please try again. Right click on image and show us the resultant HTML from the DOM.

2 Likes

Hi Russ,

For some reason, was not abe to inspect it using Firefox, tried it with Chrome and this is what I see:

inspect

Do you know if the input’s id attribute is static. If it is, then for the element’s xpath use:
id("C28_W97_V99_V100_V101_btadminh_struct.object_id")

I’m not sure, so for me to assist you in creating a solid xpath to your input element, I might start at the label, ID, and traverse to the input–or you can run the page again to see if the same id shows or snag more HTML that displays the label and input elements.

String sLeadID_Accept = WebUI.getAttribute(findTestObject('Harmony_OR/Page_finally/input_AcceptID'), 'value')

WebUI.comment("Lead ID is: ${sLeadID_Accept}")

We need to see this page opened in browser in action. However this url seems to be configured to be private; you can see it but others on the public Internet can not.

You can save this page into a single file (MIME HTML format), and share it by attaching the *.mht file to this topic.

How to save the page as a MHT file?
You can do it quite easily by Chrome.

  1. open the target URL in Chrome.

  2. right-click on the page. you will see “Save As” menu, choose it

  1. choose “Web page, Single File” as the Format; then Save it

  1. You will get a file with extension .mht. This is the MIME HTML file of the target page.

  1. You want to double click the .mht file. Browser (Edge? Chrome) will open and the frozen copy of the target page will come up.

  2. If you share this *.mht file to others, they would certainly be able to see the page on their side!

Please make sure before you actually sharing the file to us

  1. For security reason, is it really OK to make it public?
  2. please reproduce what you wanted to try (input “201481050” in the field), then Save it. This will make it easier for others to reproduce your issue on their side.

Thanks for the detailed explanation of how to save the page. Sharing the file below:

https://ict.wdf.sap.corp/sap(bD1lbiZjPTAwMSZkPW1pbg==)/bc/bsp/sap/crm_ui_start/default.htm

The id generated is a dynamic value which needs to be captured everytime the script is getting executed

If the URL is redirecting to the home screen, under ‘Recent Items’ click on the file name:

and it will take you to the page in which the dynamic ID has to be captured:

the input id is dynamically generated

@saumil.sah,

I am one Katalon users, I think that we are able to capture the value of the ID. Because I cannot access to your page so that I just provide idea I simulate from my side, base on that you can apply in your situation

See screenshot below:

Imaging that the text ‘Login’ is the static label ‘Id’
Imaging that the text ‘Please login to make appointment.’ is your dynamic id

The point here is to capture object dynamic id

Because the Id is dynamic, we cannot known the rule to generate that number so that we cannot capture its directly. However, the text ‘Id’ is static, and it is rarely to change to another one. So, we can capture the text Id first. Then, identify the relationship between the static text ‘label’ and dynamic id (based on xpath)

Once again, we capture object dynamic id based on the unchanged object (this case we use label Id)

  • With screenshot above, first, we identify the label, we have xpath: //h2[normalize-space(.)=‘Login’]
  • We see that the Id displayed next to label, using following-sibling to find it

Here is the xpath we need to find://h2[normalize-space(.)=‘Login’]/following-sibling:: p

Based on that ide, for your case, find the unchanged object first then use it to find your id

Hope it is useful.

FYI

No, you haven’t shared a file.
You shared a URL of your web site again, which is not available to others.

The file format (.mhtml) is not being supported here

Why not put the file into a .zip file and share the archive here

Hopefully this works

Test.zip (398.5 KB)

@saumil.sah

Thank you for sharing the MIME HTML of the target web page.

I could see the HTML of your target. I looked at the HTML source. I was surprised to find the HTML is terribly complex. This page is one of the most difficult HTMLs to test that I have ever seen.

  • It uses <iframe> in which <frameset> tags are located. <frameset> tags are even nested!
  • It is not an usual HTML4 or HTML5. It uses XHTML. It contains unique nodes like <thtmlb:grid xmlns:thtmlb="CRMThinHTMLBLibrary" .
  • It uses the bad-old Table layout. It has so many nested <table> tags to control the layout of the page presentation. I guess, this HTML was initially developed at least 20 years ago.
  • The element you want to select has no id or name attribute. So you have to use tricky technique. You would start with locating a certain element with some handy identification, then you would navigate to the target element using some XPath axis (following-sibling:: etc).

This page is created by “SAP”. Oh, it’s a great HTML — I would never be able to develop such mess.

I am 100% sure that the Katalon’s Spy & Recorder tools can not deal with this complex HTML. The Test Objects generated by these tools will never work. You shouldn’t expect Recorder to help you for this page.

The target HTML contains a code fragement like this:

<thtmlb:grid xmlns:thtmlb="CRMThinHTMLBLibrary" cellspacing="1" columnsize="1" height="100%" rowsize="2" width="100%">
<thtmlb:gridcell colspan="1" columnindex="1" rowindex="1" rowspan="1">
...
</thtmlb:gridcell>
</thtmlb:grid>

Here you can find a code fragment xmlns:thtmlb="CRMThinHTMLBLibrary" — this is called XML Namespace.

I tried to find how to write a XPath that can select the node
<thtmlb:grid xmlns:thtmlb="CRMThinHTMLBLibrary"
See https://github.com/kazurayam/saumil.sah/blob/master/Scripts/TC1/Script1650410352052.groovy for my code. But I couldn’t. I think that the XPath expression

//*[local-name()='grid']

should work, but actually it doesn’t. I do not see why.

The element containing the text “201481050” is located under the <thtmlb:grid> element. Therefore, I think, any attempt to get access to the element using WebUI.getAttribute() and any other WebUI Keywords will fail. … Of course, some else other than me may find a way to select the target node. Who knows.

I fear this HTML by SAP. I do not like to touch it anymore.

@saumil.sah

I would advise you to abandon the idea of testing this page using Katalon Studio.