I have next two test case:
I want to use from TC1 printed URL to TC2 test case?
Can you help me?
TC1
WebUI.openBrowser(’’)
WebUI.navigateToUrl(‘Google’)
WebUI.setText(findTestObject(‘Object Repository/New Folder/Page_Google/input_Conectai-v_q’), ‘testing’)
WebUI.click(findTestObject(‘Object Repository/New Folder/Page_Google/input_Eliminai_btnK’))
System.out.println(WebUI.getUrl())
WebUI.closeBrowser()
TC2
WebUI.openBrowser(’’)
WebUI.navigateToUrl(‘TC1 printed URL’)
WebUI.setText(findTestObject(‘Object Repository/New Folder/Page_Google/input_Conectai-v_q’), ‘testing’)
WebUI.click(findTestObject(‘Object Repository/New Folder/Page_Google/input_Eliminai_btnK’))
System.out.println(WebUI.getUrl())
WebUI.closeBrowser()
From TC1, you can try Call Test Case and call TC2. TC2 can return a result (the URL you need) back to TC1.
https://docs.katalon.com/katalon-studio/docs/call-test-case.html
I had succeed to make that work, but take too long to make again TC1 and then run TC2. That means to make TC1 twice.
Will be easy for me to print from TC1 Url in to a text file and then to take that Url from text file and execute TC2.
I can’t find something similar.
I’ve been able to make that work, to take a Url from the TC1 in a excel file:
WebUI.openBrowser(’’)
WebUI.navigateToUrl(‘https://www.google.ro’)
WebUI.delay(1)
WebUI.setText(findTestObject(‘Object Repository/New Folder/Page_Google/input_Conectai-v_q’), ‘testing’)
WebUI.delay(1)
WebUI.click(findTestObject(‘New Folder/Page_Google/input_Eliminai_btnK’))
WebUI.delay(1)
String results = WebUI.getUrl()
WebUI.delay(1)
CustomKeywords.‘myPack.WriteExcel.demokey’(results)
WebUI.delay(1)
using an cutom keyword:
public class WriteExcel {
@Keyword
public void demokey(String name) throws IOException{
FileInputStream fis = new FileInputStream(“D:\Demo.xlsx”);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheet(“Sheet1”);
int rowCount = sheet.getLastRowNum()-sheet.getFirstRowNum();
Row row = sheet.createRow(rowCount+1);
Cell cell = row.createCell(0);
cell.setCellType(cell.CELL_TYPE_STRING);
cell.setCellValue(name);
FileOutputStream fos = new FileOutputStream(“D:\Demo.xlsx”);
workbook.write(fos);
fos.close();
}
}
After that from excel file I’m importing in TC2:
WebUI.openBrowser(’’)
WebUI.navigateToUrl(findTestData(‘URL/URL1’).getValue(Search_URL))
WebUI.delay(2)
WebUI.waitForElementPresent(findTestObject(‘New Folder/Cautari referitoare’), 30)
WebUI.scrollToElement(findTestObject(‘New Folder/Cautari referitoare’), 0)
WebUI.takeScreenshot()
WebUI.closeBrowser()
But when I use Test suite to run Tc1 and Tc2, Test Data, not is update on time the excel file, in that case TC 2 can’t take Url to continue testing.
Error:
02-27-2019 01:15:22 PM navigateToUrl(findTestData(“URL/URL1”).getValue(Search_URL))
Elapsed time: 0.067s
navigateToUrl(findTestData(“URL/URL1”).getValue(Search_URL)) FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: com.kms.katalon.core.testdata.reader.SheetPOI.getValue() is applicable for argument types: (java.lang.String) values: [https://www.google.ro/search?source=hp&ei=uXB2XILqBI6kacnDpsAI&q=testing&btnK=Căutare+Google&oq=testing&gs_l=psy-ab.3..0l10.1465.1499..2585...0.0..0.82.305.4…0…1…gws-wiz…0…0i131j0i10.zZK5Sfztw0Q]
Possible solutions: getValue(java.lang.String, int), getValue(int, int), getClass(), getType(), getAt(java.lang.String)
at TC2.run(TC2:18)
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:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:129)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:112)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:81)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:149)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1551266103818.run(TempTestSuite1551266103818.groovy:36)