Web element with id: 'Object' located by 'example' not found when trying to run the javascript to click the object

Hi,

I have tried to click on an option(Check box) on the page by trying various ways like enhancedClick, Check. In this case the step passes but no action is taken. Then I tried using the below code as my customkey and call it in the test case:

public class CommonKeywords {

** /****
** * Click Web element**
** /*
** @Keyword**
** def clickUsingJS(TestObject to) {**
** WebDriver driver = DriverFactory.getWebDriver()**
** WebElement element = WebUiCommonHelper.findWebElement(to,30)**
** JavascriptExecutor executor = ((driver) as JavascriptExecutor)**
** executor.executeScript(‘arguments[0].click()’, element)**
** }**
}

Call in the test case:
CustomKeywords.‘click.CommonKeywords.clickUsingJS’(findTestObject(‘Object Repository/Verify Centrelink/Reuse Button/Refuse span’))

However, when I use this method I get an error that the ‘Object’ located by (‘Object Repository/Verify Centrelink/Reuse Button/Refuse span’) not found.


I guess the inspect option for the body of the application is not accessible as well.

Can anyone help and let me know what could be the solution.