I am running Ubuntu 22.04, with Firefox 148, and Selenium, with the geckodriver version 36.0.
I have written a small HTML file and Python script to highlight the issue.
The HTML - which I named "test.html" is as follows:
alskndafnsgkmsgn
slkdgj slgh ;iszj g;jz;x
The HTML works in Firefox, just not with Selenium.
The Python file is as follows:
#!/usr/bin/python3
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from pprint import pprint
import time
def highlight( element):
"""Highlights a Selenium WebDriver element to indicate successful selector targeting."""
driver = element._parent
def apply_style(s):
driver.execute_script("arguments[0].setAttribute('style', arguments[1]);", element, s)
original_style = element.get_attribute('style')
count = 0
colors = ['yellow', 'red']
while count < 10:
if ((count % 2) == 0):
background = colors[0]
border = colors[1]
else:
background = colors[1]
border = colors[0]
apply_style("background: %s; border: 2px solid %s;" % (background, border))
time.sleep(0.2)
count += 1
apply_style(original_style)
url = "file:////test.html"
options = Options()
firefox_profile = FirefoxProfile()
firefox_profile.set_preference("javascript.enabled", False)
options.profile = firefox_profile
driver = webdriver.Firefox(options=options)
pprint(driver.capabilities)
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
driver.get( url )
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[text()="Help"]')))
element.click() # This command waits until the element is ready for clicking.
highlight ( element )
element.click()
The "highlight" function was copied from another topic with a similar issue, and shows that the button has been correctly identified, yet still doesn't respond to the click.
The output is as follows:
./test.py
/test.py:40: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
firefox_profile = FirefoxProfile()
/test.py:42: DeprecationWarning: Setting a profile has been deprecated. Please use the set_preference and install_addons methods
options.profile = firefox_profile
{'acceptInsecureCerts': True,
'browserName': 'firefox',
'browserVersion': '148.0.2',
'moz:accessibilityChecks': False,
'moz:buildID': '20260309231353',
'moz:geckodriverVersion': '0.36.0',
'moz:headless': False,
'moz:platformVersion': '6.8.0-101-generic',
'moz:processID': 1196767,
'moz:profile': '/tmp/rust_mozprofileOYDFl5',
'moz:shutdownTimeout': 60000,
'moz:webdriverClick': True,
'moz:windowless': False,
'pageLoadStrategy': 'normal',
'platformName': 'linux',
'proxy': {},
'setWindowRect': True,
'strictFileInteractability': False,
'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000},
'unhandledPromptBehavior': 'dismiss and notify',
'userAgent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:148.0) '
'Gecko/20100101 Firefox/148.0'}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I did also try using the JavaScript click examples I found, with the same result.