What is the difference between native WebDriver.click() and JS .click()?

203 views
Skip to first unread message

Max Boring

unread,
Dec 15, 2017, 9:12:55 AM12/15/17
to Selenium Users
In my really weird case I have a dropdown I want to expand. It is visible, not overlapped, I have all sorts of Implicit waits, page load timeouts and so on, of course everything works fine in FF and Chrome.
If I send element to smth like
driver.executeScript("arguments[0].click();", element);

, then the dropdown expands, but if I try:
element.click();

or
new Actions(driver).click(element).build().perform();

or
element.sendKeys(Keys.ENTER);

then the element is just slightly blinks without expanding.
Any idea, my dear friends?

I'd like to know in detail, but to me having no experience in C++ for analyzing IEDriverServer.exe on my own =)

shre...@gmail.com

unread,
Dec 15, 2017, 1:06:42 PM12/15/17
to Selenium Users
If you are trying to operate on a drop-down box, you should be using a 'Select' class object. See if below url helps you with the detail:
https://www.guru99.com/select-option-dropdown-selenium-webdriver.html

~ Sreekanth

Max Boring

unread,
Dec 18, 2017, 3:06:29 AM12/18/17
to Selenium Users
This is not related to the question - first, I don't have native controllers and there's no <select> in my DOM tree, second, I don't really care how to handle what, I only want to knw the difference between JS click and click that Selenium provides out of the box.

Joshua Burns

unread,
Dec 18, 2017, 9:45:55 AM12/18/17
to Selenium Users
To my understanding webdriver .Click() method simulates native events while using a JS.click is akin to a synthetic event https://github.com/SeleniumHQ/selenium/wiki/Advanced-User-Interactions#native-events-versus-synthetic-events

Max Boring

unread,
Dec 19, 2017, 3:33:39 AM12/19/17
to Selenium Users
Joshua, thank you for sharing the link!
According to the table, IE supports native events, not synthetic, while in my case it's the opposite way - JS works, neither WebDriver does! =(
Reply all
Reply to author
Forward
0 new messages