I’m trying to do an automation process on a website and I’m having a problem clicking a button in Selenium headless mode.
When I run the same code without the headless option, the click works.
Here is the code used to click the button:
imprimir = driver.find_element(By.XPATH, “(//*[name()=’path’][@fill=’currentColor’])[18]”)
ActionChains(driver).move_to_element(imprimir).click().perform()
And here is the button elements:
No error appears when debugging the code, but the action is simply not performed.
Clicking this button opens a new tab with a PDF file that will be downloaded to the user’s computer.
OBS: I’m using python plus selenium.
OBS2: There is more than one button with the same name in the page.
I tried using the following code to click but without success:
imprimir=driver.find_element(By.XPATH, “(//*[name()=’path’][@fill=’currentColor’])[18]”)
driver.execute_script(“arguments[0].dispatchEvent(new Event(‘click’));”, imprimir)
1