Is possible to execute curl in Karate tests?

后端 未结 1 1393
无人及你
无人及你 2021-01-15 20:51

I need to run some test that use a NTLM proxy. Due to Karate doesn´t support NTLM proxy, I think that if karate can "execute" a curl command like below, I will get

相关标签:
1条回答
  • 2021-01-15 21:08

    Yes, Karate has very good CLI support, if curl is present on your OS, it can be done. See this answer for details, available in 0.9.6 https://stackoverflow.com/a/62911366/143475

    In your case, try first with karate.exec()

    * def result = karate.exec("curl -X GET 'https://someaddress.com/cats?Status=completed' -u siteuser:sitepasswd    --proxy-ntlm --proxy-user ckuser:ckpasswd --proxy internal-ntlm-proxy:8080 -s")
    

    And result will contain the console text. Note that there are regex helpers to make scraping values out easier, for e.g.:

    * def token = karate.extract(result, 'some(pattern).+', 1)
    
    0 讨论(0)
提交回复
热议问题