Do you get any errors?
I tried it with chromedriver and it worked fine (although code a bit different (see below)):
result:
I tried it with chromedriver and it worked fine (although code a bit different (see below)):
from selenium import webdriver from selenium.webdriver.chrome.options import Options import os class TryDucky: def __init__(self): os.chdir(os.path.dirname(__file__)) self.duck() def duck(self): chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--log-level=3') browser = webdriver.Chrome(chrome_options=chrome_options) browser.get('https://duckduckgo.com') # Try to find something (otherwise wont see anything since headless) search_comment = browser.find_element_by_xpath('/html/body/div/div[2]/div/div/div[3]/div/div') print(f'\n{search_comment.text}') if __name__ == '__main__': TryDucky()Don't forget if headless, you won't see anything until you actually print it.
result:
Output:The search engine that doesn't track you. Help Spread DuckDuckGo!
options part of code courtesy snippsat