headless option not working selenium python

Wassim Maestro

here is the code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.options import DesiredCapabilities
PATH='C:\Coding_projects\chromedriver.exe'
options = Options()
driver=webdriver.Chrome(PATH,options=options)
def open_ouedkniss():
    
    options.add_argument('headless')
    driver.get("https://www.ouedkniss.com/")
    ad_button=driver.find_element_by_id('header_interstitiel_exit')
    ad_button.click()
    search_bar=driver.find_element_by_id('menu_recherche_query')
    search_bar.click()
    search_bar.send_keys('golf 6')
    search_bar.send_keys(Keys.RETURN)
    
    
    
open_ouedkniss()

when I run the code everything works fine but the browser window still opens even with the headless option can someone tell me why?

Gurpreet Anand

Try replacing this line in your code

options.add_argument('headless')

with

options.add_argument('--headless')

Also write above line after options = Options() code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Python Selenium Chromedriver not working with --headless option

--headless is not an option in chrome webdriver for selenium python

add extension with option headless selenium python

Python Selenium:firefox headless option not working with Firefox 52.8.0 (32-bit)

python proxy in selenium firefox headless not working

Selenium Python Headless Webdriver (PhantomJS) Not Working

Selenium Python Paste Not Working in Headless Mode

Python Selenium Headless download

Selenium working with Chrome, but not headless Chrome

Headless Selenium suddenly stopped working

Select drop down option using Selenium. Headless chrome. Python

chrome driver headless option is not working for link?

Selenium headless not working with custom profile selection

Is my Selenium Chrome Headless browser working as it should?

Selenium only working in non-headless mode?

Selenium browsing with headless isn't working?

Headless Chrome (Selenium) requests not being submitted/ working

Login to stackoverflow using selenium is working but using scrapy python is not.How can I login with headless browsing?

python selenium headless chromedriver not loading full page when it was working the day before with no changes to the code

How to pass a headless option for my driver using Java and Selenium?

selenium giving an unknown error when adding --headless option

How to use headless driver in Python using Selenium

Double Click does not work with headless Selenium in Python

selenium python chrome headless mode unsupported

Using PhantomJS for headless browser in Selenium - Python

How to make firefox headless programmatically in Selenium with python?

Scrapyng AngularJS with Selenium in Python in Chrome headless mode

python - selenium firefox portable headless fails

Disable proxy via Python for Selenium with headless Chrome