How to make iframe xpath dynamic

Hi everyone,
my xpath is
//*[@id=“ctl00_cphMain_RequirementGrid_ctl00_ctl09_Detail20_ctl02_ctl03_Func_Req_txt_contentIframe”] which is an iframe. every time the value (ctl00_ctl09_Detail20_ctl02_ctl03_) are getting changed. Thus, katalon didn’t identify the iframe and gives me error. I am really new to katalon and wants to know how to resolve it?

Please share the HTML for your iframe, as well as some of the surrounding elements. We need to see this in order to give you a strategy.

<iframe frameborder="0" src="javascript:'<html></html>';" id="ctl00_cphMain_RequirementGrid_ctl00_ctl06_Detail10_ctl02_ctl03_Func_Req_txt_contentIframe" title="Rich text editor with ID ctl00_cphMain_RequirementGrid_ctl00_ctl06_Detail10_ctl02_ctl03_Func_Req_txt" style="width: 100%; height: 219px; margin: 0px; padding: 0px;">Your browser does not support inline frames or is currently configured not to display inline frames.</iframe> Pls check it.

Try this xpath:

//iframe[contains(@title, 'Rich text editor')]


Tell the developers this:


is nonsense.



works (renders 2) but is essentially useless and pointless.


Agreed. Was gonna mention that this implementation was… unconventional… :rofl: But thought better of it.

Thanks Brandon. It works

1 Like

will surely let developer knows. Thanks for advice.

Hello @Brandon_Hein @Russ_Thomas , I have lots of elements which are dynamic as above. Given solution is not working for every elements. Can you pls provide me any document, link or videos that help me to understand how to create dynamic paths?

“Dynamic” is a pretty broad term. I think you really just need to learn all the tools that the language has to offer:

1 Like

This XPath expression makes an equality test against the full ID value. But this approach is not the only method to select a HTML element. There are many alternative ways.

For example,

  1. The leading part of the @id : "ctl00_cphMain_RequirementGrid" looks unique enough for identifying the element, doesn’t it? If so, an alternative XPath could be:
    //*[starts-with(@id, 'ctl00_cphMain_RequirementGrid')]

  2. How many <iframe> elements do you have in the HTML? If the number of <iframe> is fixed (for example 2 iframe elements), then you can identify each <iframe> elements by the following XPath.

  3. The @title attribute has value "Rich text editor with ID ...". Does it uniquely identify the <iframe> element in the page? If so, you can write
    //iframe[contains(@title, 'Rich text editor')]

  4. The content text: "Your browser does not support inline frames or is currently configured not to display inline frames" looks unique. You can identify the <iframe> element by the text. For example
    //iframe[contains(text(),'browser does not support inline frames')]

1 Like

There is no single Silver Bullet that solves everything. You have to invent solutions for each of all elements that you want to select.

The following XPath tutorial could be informative.

1 Like

@kazurayam Thanks for sharing. I understand each solution is used for all the time. Your shared document helps me to learn better.