1

Karate Interop works great with my simple examples in script however facing problem with this specific method. Am I missing something here? Appreciate your help.

Steps from Sample scenarios

* configure driver = { type: 'chromedriver', executable: '/Users/vxt82/Apps/chromedriver', showDriverLog: true , readTimeout: 120000, httpConfig: { readTimeout: 120000 }}
* driver 'http://XXXXXX.XXXX'
* def searchLocators = read('classpath:folder-name/locators/search-page.json').SearchPage.search
* table searchData
  | txtNumber| txtSsn  |  btnSearch | dataExpectedValues |
  | 'L02'| 'XXXXXX' | "-"   | ["999XYZ","L02","LAST_PQ02","FIRST_PQ02","3211","P","","","","","","01/01/2020","01/31/2020","","Update","Passed","View"]|
  | 'L02'| 'XXXXXX' | "-"   | ["999XYZ","L02","LAST_PQ02","FIRST_PQ02","3211","P","","","","","","01/01/2020","01/31/2020","","Update","Passed","View"]|
* utils.ui.printClass(driver)
* utils.ui.printClass(searchLocators)
* utils.ui.printClass(searchData[0])
* utils.ui.performAutomatedFormFilling(driver,searchLocators, searchData[0])

Java Methods:

public static void performAutomatedFormFilling(WebDriver driver, LinkedHashMap<Object,Object> locators, LinkedHashMap<Object,Object> dataToSearch){
.....
}
public static void printClass(Object o){
    System.out.println("Class Name: "+ o.getClass());
}

Console Output:

Class Name: class com.intuit.karate.driver.chrome.ChromeWebDriver
Class Name: class java.util.LinkedHashMap
Class Name: class java.util.LinkedHashMap

sample.feature:68 - no step-definition method match found for: utils.ui.performAutomatedFormFilling(driver,searchLocators, searchData[0])

UPDATE: Just a side note. I tried another way by modifying method signature to match with call as below, However no luck.

public static void performAutomatedFormFilling(Object driver, Object locators, Object dataToSearch){
    .....
} 
Josiah
  • 207
  • 3
  • 13
Vikas Thange
  • 230
  • 2
  • 13

1 Answers1

0

Yes, Karate can get confused with complex JS expressions, here I think the square brackets are the problem. I propose 2 options:

* (utils.ui.performAutomatedFormFilling(driver,searchLocators, searchData[0]))

Or 2 steps:

* def searchArg = searchData[0]
* utils.ui.performAutomatedFormFilling(driver, searchLocators, searchArg)

I do think you have started to over-complicate your tests. Do you really need so many utils. Just try to make your tests readable, even if it means repeating yourself a little. Refer this answer - especially the links: https://stackoverflow.com/a/60562941/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank you so much for quick reply as always, I tried both the ways but it's still a problem. Do you it is because of the array inside the data table? It was working fine before I add the array. If it's because of array please suggest a way to such value? thanks – Vikas Thange Mar 18 '20 at 19:30
  • Please have a look at the data table value for column 'dataExpectedValues' – Vikas Thange Mar 18 '20 at 19:30
  • @VikasThange I give up. maybe this is a bug - so please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Mar 18 '20 at 19:48
  • No worries. Will create an issue in sometime. Thanks for looking into it – Vikas Thange Mar 18 '20 at 20:36
  • I deleted the steps from scenario & Java method, Rewrite everything again and surprisingly it's working fine. exactly same code, data and steps. Wondering what mistake I did in first place and was stuck for 2-3 days. Thank you so much for reviewing the question and providing answer. Not sure what to do about this question , Please suggest. – Vikas Thange Mar 19 '20 at 00:03