i’m here to ask you if there’s a way to store in a variable a dynamic string that is generated in the response of a rest API (POST) in HTML format. I have to use the saved string in the body of another request.
How can i do?
Thank You
hi, i’m not able to write any code since i’m not a programmer. I have to use the string extracted from the reponse of the first post api in the body of another post request. Thank you
It is a post request that gives a html response. Its a radlogin software page that gives infos on authentication. Some of that info must be reused in another post request to make an accounting start (on Radius Server).
You can call WebUI.* keywords and WS.* keywords mixed in a Test Case. No problem.
You want
WebUI.openBrowser(“starting url “)
WebUI.verifyElementPresent(findTestObject(“name of the Test Object which points the element of your interest”, timeout))
String s = WebUI.getText(findTestObject(”…”))
// pass value of the variable “s” into the REST Request, and then
Response res = WS.sendRequest(…)
…
Just try to write your test case manually in the Script mode.
Please mind, you need to write the required import statements.
Thank you, i tried you solution but katalon gives me an error:
Test Cases/Prova_ACCT_id FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: Script1657186951485.string() is applicable for argument types: (java.lang.String) values: [“1657204950L12tsw”]
Possible solutions: toString(), toString(), print(java.lang.Object), print(java.io.PrintWriter), sprintf(java.lang.String, java.lang.Object), print(java.lang.Object)
at Prova_ACCT_id.run(Prova_ACCT_id:48)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:442)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:433)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:412)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:404)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:281)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1657204877622.run(TempTestCase1657204877622.groovy:25)
i ended up writing result = WebUI.getText(findTestObject(”…”)) and it works but it extract the id between the “”. How can i extract only the value without the “”?
You want to get started with WebUI testing in Katalon Studio. See
Recorder tool will let you get started, but not enough.
You, a programmer, should change the test case editor from “Manual mode” to “Script mode”, edit the test case script in the Script mode, so that the test case can deal with the URL of your target application.
In order to write appropriate code, you are required to read and understand HTML source code of your target web page.
In order to read HTML source, you should learn how to use DevTools of web browser.
Have a look at the following tutorial.
As for XPath, the following tutorial would be good:
As for CSS Selector, … well, there are hundreds and thousands of tutorials for CSS on the Internet. Whichever you like will do.