0

I have a question regarding what is the best Practice for Clicking the Element

1)  Click by Selenium Webdriver Click Event or

2)  or below ClickbyJS method.     

   public static void ClickByJS(IWebElement element, string name)
    {
        try
        {
            IJavaScriptExecutor js = _driver as IJavaScriptExecutor;
            js.ExecuteScript("arguments[0].click();", element);
        }
        catch (Exception ex)
        {
            throw new ApplicationException("Unable to click " + name, ex);
        }
    }

Reason for asking is due to new Specflow version 2.53 and Firefox 45 most of the places normal selenium click event is not working the way it used to work. So i'm replacing most of the click event with above ClickbyJS method but i need to know is that the right solution for it ?

please let me know if i use ClickByJS is not over killing actual action of users towards browser.

0

1 Answer 1

1

Click simulated by WebDriver on a browser is similar to what actual user do as compared to one invoked using javascript. But with WebDriver not all the events can be automated flawlessly with all the web browsers, in fact with different versions of the same Web browser also. On the other hand with JS you will not face such problems.

Again choice is yours whether you want to simulate approx exact action of user or robust script that can be executed without any overhead of browser and it's version.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.