Tuesday, 8 June 2021

Multiple ways of clicking on Element with Selenium

We might be suprising sometimes while executing selenium script, though element is getting recognized, it is not clicking on the element. There could be various reasons for that 1. the element is rendering in the DOM which is not loaded but it is availalbe on the page 2. Element is available but it's href link made with # at the end, therefore it won't navigate any reference link But for the 1st reason we can use alternative options and make our selenium script working. Basically there 4 ways available to click on element with selenium. Following are the ways.


1. .Click

2. ((JavascriptExecutor) driver).executeScript("arguments[0].click();", yourelement);

3. yourelement.sendKeys(Keys.RETURN) or .sendKeys(Keys.ENTER)

4. Actions class: Actions actions = new Actions(driver); actions.click(signOnImage).perform();

25 comments:

  1. Best Automation Anywhere course with placement assistance. Please visit our website for more info: Best Automation Anywhere Training Institute in Chennai

    ReplyDelete
  2. Choosing the best data science course depends on your current skill level, learning style, and career goals.
    check out Best Data Science course 2024 in kochi

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete