Hi, I need to create a TC in which I filter a table by setting some text in a text box and then click on the element that appears after I filter.
In my TC I enter a page and then the text I need, Then the page automatically filters the info in the table with out me pressing enter. The thing is that Katalon does not make this so whenever I do a click action, it does not click the element I want.
This is the way in which I filter in the TC:
.
.
.
CustomKeywords.‘keywordPrueba.CustomFunction.clickUsingJS’(findTestObject(‘Object Repository/Page_Pruebas/input_Prueba Descripcion1_vPRUEBADESCRIPCION1’),
30)
WebUI.executeJavaScript(‘arguments[0].value='NITRITOS EN ORINA'’, Arrays.asList(elementPrueba))
WebUI.delay(3) //I do this to wait for the table to be properly filtered but nothing happens
.
.
.
So apart from the delay I also tried waiting for the new table to appear but it does not work. Any other suggestions?
Here is the filter with its text box and its html and the table I want to filter:
Thanks for the quick answer
After I do exactly that this is the error I am facing:
10: js = "
arguments[0].value=‘NITRITOS EN ORINA’;
arguments[0].onchange();
"
2019-07-24 11:01:52.023 DEBUG testcase.NoImprimeEnInforme - 11: executeJavaScript(js, Arrays.asList(elementPrueba))
2019-07-24 11:01:52.406 ERROR c.k.k.core.keyword.internal.KeywordMain - Unable to execute JavaScript. (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$4.call(Unknown Source)
at NoImprimeEnInforme.run(NoImprimeEnInforme:52)
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 TempTestCase1563976894373.run(TempTestCase1563976894373.groovy:21)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token
Once again, thanks for the reply
1)
In regards to ¨getValidStructFld¨ the entire error in the console is like this:
com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.executeJavascript(ExecuteJavascriptKeyword.groovy:42)
at com.kms.katalon.core.webui.keyword.builtin.ExecuteJavaScriptKeyword.execute(ExecuteJavascriptKeyword.groovy:37)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.executeJavaScript(WebUiBuiltInKeywords.groovy:3787)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$executeJavaScript$4.call(Unknown Source)
at NoImprimeEnInforme.run(NoImprimeEnInforme:53)
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 TempTestCase1563978022921.run(TempTestCase1563978022921.groovy:21) Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read property ‘getValidStructFld’ of null
I do not have something like this in my code: something.getValidStructFld();
2) I do think its caused by onChange
3) What do you mean by this: You could try a different tack… use WebUI.sendKeys .
Ive tried to simulate an ENTER by using send keys before but nothing happens. I mean, the filtered table should appear while you are typing whatever you need to set in the text box of the filter
Ok so if I use blur it does not give me an error but it does nothing.
In regards to sendKeys, I tried to use it once again and it says that the element is not interactable.
The filter part should work but I could try clicking any other element without filtering. I mean, i am really confused by this problem. The first time I recorded it… it worked perfectly.
Which usually means you’re not waiting long enough for the element to be initialized properly.
I considered that. Click something after the field is filled with your filter. But really, it shouldn’t be this complicated.
Regarding blur/onchange - it now seems that the event in question is using something higher up in the hierarchy. What that is, is difficult to say. If you’re determined to get this right, here’s what I would do.
Switch to Firefox.
Inspect the element.
When Firefox shows the element, look for event at the end of the line.
Click on event, take a screenshot, post it here.
If there’s no event attached to that element, look for the nearest ancestor element and follow the steps above again.
OMG !!! It worked !! You are a genius.
It told me element was not interactable. Then you told me it was because I was not waiting long enough so I did that and it worked.
Thank you very much !