Python Selenium producing different results on Ubuntu 22.04LTS Desktop and Ubuntu

On Ubuntu desktop (22.04lts) my script works perfectly, the exact same script running on an Ubuntu Server (22.04lts) I get intermittent Element Click intercepted errors, its not clear why.

Its not consistent with the same URL (never observed it happening twice in a row), I don’t think its a popup. It’s not a cookie dialog. But it only ever happens on Ubuntu Sever, not Desktop.

Versions (same on both Server and Desktop)

  • Python 3.10.12
  • Selenium 4.17.2
options = Options()
options.add_argument('--headless')
options.add_argument("--no-sandbox")
options.add_argument("--window-size=1920,1080");
options.add_argument("start-maximized")
driver = webdriver.Chrome(options=options)

driver.get('https://www.website.co.uk')

xpath = '/html/body/div[1]/div[2]/div/div[1]/div/form/fieldset[2]/div[4]/button'
button = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, xpath)))
    
try:
    button.click()
except ElementClickInterceptedException as e:
    print(f"Error: {e}")