S
S
Sanchoys2282020-08-11 21:53:17
Python
Sanchoys228, 2020-08-11 21:53:17

Why is Selenium not finding the button in headless browser mode?

When starting the webdriver in normal mode (the browser window is visible), all buttons are pressed normally, in headless mode it
writes an error:
Message: no such element: Unable to locate element
The code itself:

opts = Options()
opts.add_argument('--headless')
driver = webdriver.Chrome(options = opts)
driver.maximize_window()


The button call itself:
driver.find_element_by_xpath("//*[@id='free_bonus']/div/div[2]/div["+ config["SETTINGS"]["CHOICE_BONUS"] +"]/div[2]/span").click()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question