My code worked perfectly until yesterday when I updated Google Chrome to version 110.0.5481.77. Now it's not working in headless mode:
options.add_argument("--headless")
I even tried adding options.add_argument("--window-size=1280,700")
but still not working. Although if I remove the headless option it again works correctly!