Whenever i perform click operation its navigating to footer instead of moving that page, and test case getting failed.Please give us some solution

Viewed 16

We have used JS click and normal click but it's moving to the footer.

public static void jsClick(WebDriver driver, WebElement element,String msg) {

    try {
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("arguments[0].click();", element);
        WaitUtils.staticWait(5000); //3000
        LoggerHelper.log().info(msg);
    } catch (Exception e) {
        LoggerHelper.log().error("Not able to click", e.getCause());
    }
}
1 Answers

You don't click on a button in Selenium by injecting as JavaScript into it. You should use the Selenium driver in order to click:

element = driver.findElement(By.CSS, 'button[id="ButtonID"]')
element.click()

In you code example you are not using the Selenium plugin.

Related