SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.49k stars 8.15k forks source link

[🐛 Bug]: Selenium - Firefox Driver - Button press doesn't work #12881

Closed Ethan-DSB closed 1 year ago

Ethan-DSB commented 1 year ago

What happened?

I've been running into an issue while using Selenium with Firefox. The script has to navigate to a webpage and then click a button in order to set the store location. However, when it clicks the button it doesn't actually succeed in changing the store.

I also converted the script to use the ChromeDriver instead and it worked perfectly. I don't understand why it's having this issue on Firefox. I've included version numbers and my script below.

Video of the script failing: https://streamable.com/73oa74

How can we reproduce the issue?

import random
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.firefox.service import Service as FirefoxService

# Specify the path to the GeckoDriver executable
geckodriver_path = r'C:\Users\LAPTOP-EDB\Desktop\geckodriver.exe'

# Create a FirefoxService instance with the executable path
service = FirefoxService(executable_path=geckodriver_path)

options = FirefoxOptions()
options.add_argument("--log-level=3")
options.add_argument("--window-size=800,500")

# Set permissions.default to 0 to accept any permissions requested by the website
options.set_preference('permissions.default', 0)

# Create a Firefox WebDriver instance using the service and options
driver = webdriver.Firefox(service=service, options=options)

driver.get("https://www.extrafoods.ca/store-locator/details/9021")

set_store_button = WebDriverWait(driver, 15).until(
    ec.element_to_be_clickable((By.CSS_SELECTOR, ".location-pickup-confirmation__actions__set-store"))
)

time.sleep(3)  # wait 3 seconds after the button becomes interactable

actions = ActionChains(driver)
actions.click(set_store_button).perform()

time.sleep(random.uniform(6, 8))  # Wait for the action to complete after clicking

driver.quit()

Relevant log output

1696543719908   geckodriver INFO    Listening on 127.0.0.1:32449
1696543721936   mozrunner::runner   INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "--log-level=3" "--window-size=800,500" "-- ... "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "C:\\Users\\LAPTOP~1\\AppData\\Local\\Temp\\rust_mozprofilextfp2C"
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
1696543722149   Marionette  INFO    Marionette enabled
Dynamically enable window occlusion 0
console.error: "Warning: unrecognized command line flag" "-log-level"
console.error: "Warning: unrecognized command line flag" "-window-size"
1696543722200   Marionette  INFO    Listening on port 32457
WebDriver BiDi listening on ws://127.0.0.1:32450
Read port: 32457
1696543722338   RemoteAgent WARN    TLS certificate errors will be ignored for this session
DevTools listening on ws://127.0.0.1:32450/devtools/browser/a46e6e6b-bfcd-4e0e-bc1b-8aac65858b77
JavaScript warning: https://d3rzy2hoo29vi.cloudfront.net/assets/js/at_v1.js, line 6: WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER.
1696543739224   Marionette  INFO    Stopped listening on port 32457
JavaScript warning: https://www.extrafoods.ca/assets/2414019532087ed6577628d3f85d5d1e60018af2959, line 36: Script terminated by timeout at:
g@https://www.extrafoods.ca/assets/2414019532087ed6577628d3f85d5d1e60018af2959:36:1

Operating System

Windows 10

Selenium version

Selenium 4.12.0

What are the browser(s) and version(s) where you see this issue?

Firefox 118.0.1

What are the browser driver(s) and version(s) where you see this issue?

GeckoDriver 0.33.0

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 year ago

@Ethan-DSB, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 1 year ago

If it works in Chrome and not Firefox, you must report this to Mozilla.

github-actions[bot] commented 1 year ago

Hi, @Ethan-DSB. This issue has been determined to require fixes in GeckoDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an Issue with the GeckoDriver team.

Feel free to comment the issues that you raise back in this issue. Thank you.

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.