I am currently in the process of creating an automated test for a website, and I am encountering some difficulty trying to execute a specific function within the site's code.
Upon inspecting the developer tools, I have identified the function I need to run, and when I trigger alert('hello world')
from my script, I can see it working on the test page.
Here is the snippet of my code:
WebDriver driver = getDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
String retval = (String) js.executeScript("return theFunction()");
However, despite following this approach, I seem to be missing something. Can anyone pinpoint what might be wrong with my implementation?