Unable to resolve class WebElement when Recording? Please help

Hi @dasu07

Can you show us your script plus the import statements ? When you develop your test is there any red underline anywhere ?

Cheers !

Try “ctrl+shift+o” when you are in script mode. It will import for you any missing classes.

I sure can. Here are all my imports:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import org.openqa.selenium.interactions.Actions as Actions
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.JavascriptExecutor as JavascriptExecutor
import org.openqa.selenium.Keys as Keys

Thanks!

Forgot to include the rest of the code:
WebElement ElementA = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Multi Asset 60_comment-1596’), 30)
WebUI.executeJavaScript(“arguments[0].value=‘MOTIVERING AV MÅL 1234567890 1234567890’;”, Arrays.asList(ElementA))

WebUI.sendKeys(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Multi Asset 60_comment-1596’), Keys.chord(Keys.TAB))

WebUI.delay(5)

CustomKeywords.‘newpackage.keywordtest.clickUsingJS’(findTestObject(‘Object Repository/Page_Rdgivarstdet/i_ViArOverens’), 30)

WebUI.delay(3)

CustomKeywords.‘newpackage.keywordtest.clickUsingJS’(findTestObject(‘Object Repository/Page_Rdgivarstdet/button_Spara ml och g till agenda’), 30)

CustomKeywords.‘newpackage.keywordtest.clickUsingJS’(findTestObject(‘Object Repository/Page_Rdgivarstdet/a_G till sammanstllningen’), 30)

WebUI.delay(3)

WebElement ElementB = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Koppla rdet till en liten erfarenhet och intresse_motivation-background’),30)
WebUI.executeJavaScript(“arguments[0].value=‘Some random text BACKGRUND OCH SYFTE’;”, Arrays.asList(ElementB))
WebUI.sendKeys(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Koppla rdet till en liten erfarenhet och intresse_motivation-background’), Keys.chord(Keys.TAB))

WebUI.delay(3)

WebElement ElementC = WebUiCommonHelper.findWebElement(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Multi Asset 60_motivation-goodtoknow’), 30)
WebUI.executeJavaScript(“arguments[0].value='Some random text BRA ATT VETA BRA ATT VETA ';”, Arrays.asList(ElementC))
WebUI.sendKeys(findTestObject(‘Object Repository/Page_Rdgivarstdet/textarea_Multi Asset 60_motivation-goodtoknow’), Keys.chord(Keys.TAB))

I’m not missing classes… at least I don’t think so. I can run the script as I mentioned, I just can’t record for some reason. I don’t have any red underlines anywhere

@dasu07 I am kind of confused.

What do you mean when you say it doesn’t work when you record ?

Does the error prevent you seeing the record dialog ? Or does the dialog open but the browser is not launched, or you can’t run the test case in record dialog ? More screenshots would definitely help, try to give us as much details as you can think of.

Cheers !

Hello.
Absolutely. I can run the test just fine by clicking on the “Run” button, but if I go on “Record” mode so I can add more instructions to my test case, then it crashes.

Here’s a screenshot of the test-run. As you can see it passed all the tests without a problem:

And here’s a screenshot of the recording function failing for the same testcase indicating where it failed. I have no explanation for those errors:

1 Like

I have this same problem.

2 Likes

@ThanhTo I’ve tried a few things but nothing seems to work. Still get those errors in record mode. Any ideas what could be causing this? I didn’t thank you earlier btw. Any feedback helps.

Hi @dasu07

Our development team is looking into this issue, we will let you know !

Cheers !

1 Like

I suppose that the classpath of the Web Recorder dialog is not configured to include the jar of the WebDriver.

@kazurayam Thanks for youf feedback! In order to use the Web Recorder and “record” more tests I have to go through all the tests first so I can record more instructions and add them to the script. That’s just how the system I’m testing is built. I have to test everything else first before I get to the last instruction. Furthermore, it used to work before… the problems with the Web Recorder came up quite recently.

As I understand it it’s the webrecorder that saves all the new test objects in the repository which I later use in the script.

Hi @dasu07

This is interesting. Did you update to a new version recently ? Can you confirm that this issue is present across different versions of Katalon Studio ? It may help us track down the change (if exists) that introduced this issue. Please elaborate more on the “it used to work before” part.

Cheers !

Hello again!

I think I have the latest version. The client I installed is a little bit unstable because it’s on a remote desktop, not to mention the actual katalon domain is black listed for some reason. I cannot confirm this happens on different versions.

I will actually take @kazurayam 's advice and just use spymode to capture all the objects. My tests are running even better now.

I used the record mode to save time with the instructions and capture of objects but the bigger my script grows the more unstable it becomes. So far it’s working just fine with spy mode instead of record mode. Thanks for all your help!

1 Like

Hi. Glad you’re comfortable with another way. Thanks for reporting this issue anyway.

Cheers !

1 Like

Hi. I am also getting the same error. Please help. Thanks.

1 Like

Is this bug resolved yet?

Hello,
I have similar problem with my Katalon 7.4.0, but with import java.nio.file.Path

It will never be patched ?
it would be very usefull to be able to modify “advanced” test cases with web recorder

Here is my script :

import java.nio.file.Path as Path
import com.kms.katalon.core.exception.StepErrorException as StepErrorException
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW

// DEBUT initialisation variables de test

WebUI.callTestCase(findTestCase(‘Common Test Cases/Authentification si besoin’), [:], FailureHandling.STOP_ON_FAILURE)

String timestamp = CustomKeywords.‘test.common.TimeHelper.getServerTimestamp’(‘yyMMdd-HHmm’, 0, 0)

String recRef = ‘Kat_’ + timestamp

def variablesToReplace = [(‘recRef’) : recRef]

Path EDI_in_file_COMPOSED = CustomKeywords.‘test.common.ReflexShare.EDIgetComposedFile’(testName, templateFileName, variablesToReplace)

WebUI.callTestCase(findTestCase(‘EDI in injection/generic functions/EDI integrate message by HFQ300’), [(‘filePath’) : EDI_in_file_COMPOSED.toString()
, (‘partner’) : ‘EPF’, (‘messageType’) : ‘*EPF_0_AP2’], FailureHandling.STOP_ON_FAILURE)

Here is my error message :

2020-05-28 16:56:54.002 INFO c.k.k.core.main.WSVerificationExecutor - --------------------
2020-05-28 16:56:54.007 INFO c.k.k.core.main.WSVerificationExecutor - START Verification
2020-05-28 16:56:54.626 ERROR c.k.k.core.main.WSVerificationExecutor - ? Verification FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WSVerification1590677814060: 27: unable to resolve class Path
@ line 27, column 6.
Path EDI_in_file_COMPOSED = CustomKeywords.‘test.common.ReflexShare.EDIgetComposedFile’(testName, templateFileName, variablesToReplace)
^

1 error

at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
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.WSVerificationExecutor.runScript(WSVerificationExecutor.java:146)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:140)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:123)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:115)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:103)
at com.kms.katalon.core.main.TestCaseMain.runWSVerificationScript(TestCaseMain.java:127)
at com.kms.katalon.core.main.TestCaseMain$runWSVerificationScript$0.call(Unknown Source)
at TempTestCase1590677809404.run(TempTestCase1590677809404.groovy:25)

2020-05-28 16:56:54.675 INFO c.k.k.core.main.WSVerificationExecutor - END Verification

I have the same problem Katalon 7.5.5 on OSX.

Close Katalon Studio window, open your project by another IDE such as IntelliJ, VSCode, delete the folder bin.

Then open Katalon Studio and load your project again.