I'm getting the following
An error occurred: Message:
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:199:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:552:5
dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16
I'm new to Selenium. My first question is the references to chrome. I'm using firefox is this error message typical?
My real question is how do I retrieve this button?
I've tried many ways to select the element e.g.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
link = 'https://ennexos.sunnyportal.com/login?next=%2Fdashboard%2Finitialize'
driver.get(link)
try:
# Wait for the login button to be present
login_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "[data-testid='button-primary']"))
)
print("found login button!")
except Exception as e:
print(f"An error occurred: {e}")
finally:
driver.quit()
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
driver = webdriver.Firefox()
link = 'https://ennexos.sunnyportal.com/login?next=%2Fdashboard%2Finitialize'
driver.get(link)
# Wait for 5 seconds
time.sleep(5)
try:
# Wait for the login button to be present
login_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "[data-testid='button-primary']"))
)
print("found login button!")
except Exception as e:
print(f"An error occurred: {e}")
finally:
driver.quit()
I've slightly enhanced your code by adding a 5 second delay after the target site loads. This ensures that the page elements are fully rendered before Selenium tries to find the login button, which helps avoid race conditions on JavaScript-heavy pages. The script now runs reliably.