1

I am using karate framework and I want to use js function in it. Let me explain in detail

I have a requirement where in I need to fetch the id value which is dynamic inside an iframe. So I want to use getElementByTagName('iframe') function but it is not working. It says ReferenceError: "document" is not defined'

Can someone let me know what all libraries or plugins or dependencies should be added to make this work?

   * def elementId =
"""
 function()
    {
    var list = document.getElementsByTagName('iframe');
    var results = [];
    for (var i = 0; i < list.length; i++) {
        var id = list[i].id;
        if (id && id.search(/flex-microform-/) != -1) {
            return(id);
        }
    }
    return(null);
}
"""
 * def temp = call elementId
    * print temp

1 Answers1

0

You can try this library

<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
Dharman
  • 30,962
  • 25
  • 85
  • 135
Adan
  • 58
  • 2
  • 10