1

I am doing some UI automation using Karate. In this particular scenario, the goal is to navigate to a page that has a table with pagination. If there is a "next page" button, to click it, and to verify the pagination changes as expected (pagination will always return either an 8 or a 9).

I have the following code:

        * def getPagination =
        """
            function(){
                var nameVal = []
                var nextPageBtn = false
                do {
                    nextPageBtn = driver.exists('skipToNext a');
                    if (nextPageBtn {
                        driver.click('skipToNext a');
                        var getPagination = (driver.text(li[class='active'] a)).trim()
                        karate.log("The current page value is:", getPagination)
                        karate.match (getPagination == '8' || '9')
                        var getNameVal = driver.scriptAll('#names', '_.textContent')
                        nameVal.push(getNameVal)

                } 
                    } while (nextPageBtn) 
                return(nameVal);
}

I am getting the following error on the match:

org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (match) on com.intuit.karate.core.ScenarioBridge@5d32d8f failed due to: no applicable overload found (overloads: [Method[public java.lang.Object com.intuit.karate.core.ScenarioBridge.match(java.lang.String)], Method[public java.lang.Object com.intuit.karate.core.ScenarioBridge.match(java.lang.Object,java.lang.Object)]], arguments: [true (Boolean)])
- <js>.:anonymous(Unnamed:17)

Any ideas?

hungryhippos
  • 617
  • 4
  • 15
  • 1
    there's no such thing as `karate.match (getPagination == '8' || '9')` - please read this: https://stackoverflow.com/a/50350442/143475 – Peter Thomas Mar 29 '22 at 06:15
  • This is good to know, thank you @PeterThomas. I guess I cannot use this method, since JS doesn't allow us to use just "match" that we would need for the {pass: true, message: null} part. – hungryhippos Mar 29 '22 at 15:12

0 Answers0