I have the following HTML:
<button class="gbqfba" name="btnK" aria-label="Google Search" id="gbqfba"><span id="gbqfsa">Google Search</span></button>
My following code for clicking "Google Search" button is working well using java in WebDriver:
driver.findElement(By.id("gbqfb")).click();
I want to use jQuery with WebDriver to click the button. How can I do it?
I did the following (Test was run in eclipse by using TestNG framework):
WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("$('#gbqfba').click();");
Unfortunately the following error was displayed:
org.openqa.selenium.WebDriverException: $ is not defined (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 23 milliseconds
What's the wrong with my above code?