i’m tryng to make a "if and “else” in my loop.
I need make this:
Start the loop
Go to page “x”
submit value “123” in box input
wait page load IF result is = or >, save the page, ELSE, don’t save.
Restart loop with next value
I have the all code, but now the code save any pages.
My only objective is to tell the code to save only if the value of result is “= or > of 700”, if don’t, restart the loop to the next value and don’t save the page.
@felipe.dks - pLease use below code … Hope it will work for you
for(int i=0; i<=count; i++){
WebUI.naviagtetourl(xpageurl)
WebUI.setText(ele, ‘123’)
WebUI.click(submitelement)
WebUI.waitForPageLoad(30)
if(result>=value){
WebUI.click(saveelement)
}
else{
webUI.click(donsave)
}
}
Save xpath in Object repository and use as web element
Store Test Object - //div[@id=‘resposta’]/table/tbody/tr/td[4] in OR
String value = WebUI.getText(findTestOBject(Test Object)
if (value ==‘30’){
Robot robot = new Robot();
WebElement element = driver.findElement(By.id(“here your table id”)); //if not id defined then some other locator e.g className or tagName
List rows = element.findElements(By.tagName(“tr”));
for (WebElement row : rows) {
List cols = row.findElements(By.tagName(“td”));
for (WebElement col : cols) {
System.out.print(col.getText() + “\t”);
if (col.getText().equals(“30”){
//do your job here
}
}
System.out.println();
}
You need to convert your string ‘50’ to an integer 50:
String value = WebUI.getText(findTestObject("teset01"));
Integer intValue = Integer.parseInt(value);
if (intValue <= 50) {
// Do stuff...
}
else {
// Do other stuff...
}
I think this code is the solution.
But the code return an error:
Test Cases/Testes Apenas FAILED.
Reason:
java.lang.NumberFormatException: For input string: " 26"
at java_lang_Integer$parseInt.call(Unknown Source)
at Testes Apenas.run(Testes Apenas:45)
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:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1560981699590.run(TempTestCase1560981699590.groovy:21)
But the code find the correct value, because in this test, the value in the table is 26, and the code says For input string: " 26"
I see the value of table have a space before value. Is not “26”, is " 26". See?
Is this the problem? Have way to remove this space or put space before the ‘50’ ?