"WebDriver:ElementClick" for <option> fires "change" and "input" events even without any changes made
Categories
(Remote Protocol :: Marionette, defect, P3)
Tracking
(Not tracked)
People
(Reporter: alt.mholle, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Steps to reproduce:
Given the following html:
<!DOCTYPE html>
<html lang="en">
<head><title>Onchange issue</title></head>
<body>
<script> var counter = 0; </script>
<select name="dd" onchange="++counter">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</body>
</html>
When running the following Selenium commands:
driver = webdriver.Firefox()
driver.get(url)
aPath = "//select[@name='dd']/option[text()='A']"
bPath = "//select[@name='dd']/option[text()='B']"
cPath = "//select[@name='dd']/option[text()='C']"
driver.find_element_by_xpath(bPath).click()
driver.find_element_by_xpath(cPath).click()
driver.find_element_by_xpath(cPath).click()
print('Fired onchange ' + str(driver.execute_script('return counter;')) + ' times!')
Actual results:
The onchange event is triggered 3 times, meaning it fires when the value does not change.
Expected results:
When using other drivers (such as chromedriver) or manually selecting the options in Firefox, the onchange event is triggered 2 times, as it should.
Comment 1•5 years ago
|
||
Thank you for filing this bug. It's indeed an oversight and specifically a missing check if the target element is different from the currently selected element:
Updated•2 years ago
|
Updated•2 years ago
|
Comment 2•2 years ago
|
||
Fixed unexpected change and input events being fired when clicking an
already selected <option> as they should only be fired when the value
changes.
Updated•2 years ago
|
Comment 3•9 months ago
|
||
Oliver, would you have a chance to check my review comments which require an update of the patch? Thanks.
Comment 4•5 months ago
|
||
Apologies, I don't have the time to work on these patches for now.
Comment 5•1 month ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Description
•