I create a customer keyword failed

public void waitForPageLoaded() {
	WebDriver driver = DriverFactory.getWebDriver()
	ExpectedCondition<Boolean> expectation = new
			ExpectedCondition<Boolean>() {
				public Boolean apply(WebDriver driver) {
					return ((JavascriptExecutor) driver).executeScript("return document.readyState").toString().equals("complete");
				}
			};
	try {
		Thread.sleep(1000);
		WebDriverWait wait = new WebDriverWait(driver, 30);
		wait.until(expectation);
	} catch (Throwable error) {
		Assert.fail("Timeout waiting for Page Load Request to complete.");
	}
}

i want to user this code to create a custom keyword ,but failed
error
Multiple markers at this line
- Groovy:class Keyword is not an annotation in @Keyword
- Groovy:unable to resolve class Keyword , unable to find class for
please help ,thanks

The compiler is complaining about “@Keyword” - I can’t see what’s wrong because you didn’t include it.

Here is how it should look:

// imports...
import com.kms.katalon.core.annotation.Keyword

@Keyword
public void waitForPageLoaded() {
  // ...
}

If you never use Manual view, you don’t need @Keyword - you can delete it completely.

it still failed

import com.kms.katalon.core.annotation.Keyword

Please press Ctrl + Shift + O to auto import the necessary stuffs.

1 Like

thanks, its ok now

i have others question


Please help, thanks

in

public Boolean apply(WebDriver driver) {
   return ((JavascriptExecutor) driver).executeScript('yourSCript')
}

Change driver to webDriver

1 Like

thanks, its work

I’ll set Russ’s answer to be the accepted answer since it correctly solves the problem, my answer is just syntactic.