What's going on internally when I do driver.findElementById ("some id"). Click ()? does it execute javascript?

What happens inside when I do driver.findElementById("some id").click()

? does it execute javascript? I would like to understand how a click works? is it executing a java script or is it making some kind of API call?

+3


source to share


3 answers


If you specifically ask, "What happens when I do WebElement.click()

?" the answer is "It depends." Most browsers use one of two different modes when called click()

. If you are using so-called "custom events" then the click is performed using OS-level mechanisms appropriate for the platform you are running on. On the other hand, if you use "mocked events", these are clicks on an element using JavaScript. You can also tell most drivers, usually via DesiredCapability

which you want to use custom or synthetic events. Whether you use native or synthetic events in your particular case is highly browser and platform dependent, as the defaults differ from browser to browser and OS to OS.



If your question is more general, for example, "Does WebDriver use JavaScript for any of its functionality?" the answer is almost certainly, "Yes, drivers rely on JavaScript for at least some functionality." Note that this means that disabling JavaScript execution through your browser settings will almost certainly break the driver for whatever browser you are trying to automate.

+1


source


Earlier versions of selenium, Selenium RC, use javascript to inject functions when the browser loads the page, and targeted all browsers with this approach.

With the introduction of Selenium WebDriver, selenium takes advantage of native browser support for automation that is browser dependent. Thus, Firefox Plugin for Firefox, DLL for IE, Chromium supports ChromeDriver technology for Chrome. So native support versus old javascript approach.



The introductory for the web driver will fit you closer if you haven't covered it already http://docs.seleniumhq.org/docs/03_webdriver.jsp

0


source


It looks like the web driver is using simulated PLS events related to https://w3c.github.io/webdriver/webdriver-spec.html#clicking

0


source







All Articles