F
F
fandorin_official2019-06-29 14:26:04
Python
fandorin_official, 2019-06-29 14:26:04

Why in 'headless' browser mode does Selenium not click on the button?

Hello.
Maybe someone came across why in the 'headless' mode Selenium does not click on the button, or clicks somehow "virtually" (in fact, there is no click).
That is, if I write code like this:

browser.find_element_by_class_name('posting_submit.button-pro').click()

then in normal browser mode the button is pressed. In 'haedless' mode I get the error selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted
If I write code like this:
share = browser.find_element_by_class_name('posting_submit.button-pro')
browser.execute_script("arguments[0].click();", share)

or like this:
share = browser.find_element_by_class_name('posting_submit.button-pro')
webdriver.ActionChains(browser).move_to_element(share).click(share).perform()

then the button is pressed in both modes, but, in 'headless' mode, it is allegedly pressed - it is not actually pressed (the rest of the code falls).
Who can faced similar? How can this be overcome?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1001001, 2019-06-29
@1001001

do not use for haedless browser.maximize_window()
use specific size--window-size=1200,600

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question