Sometimes click method of selenium does not work. In such situations, you can use below solutions.
- Use javascript
- Use Actions class
By using javascript, you can click on any element.
By using Actions, you can click on any element.
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
WebElement element = driver.findElement(By.linkText("Log in"));
jsClick(element); public static void jsClick(WebElement element){ ((JavascriptExecutor) driver).executeScript
("arguments[0].click();",element);
}
By using Actions, you can click on any element.
WebElement element = driver.findElement(By.linkText("Log in")); clickByActions(element); public static void clickByActions(WebElement element) { Actions builder = new Actions(driver); Action click = builder.click(element).build(); click.perform(); }
What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com
No comments:
Post a Comment