From what I have read, headless and non-headless should be able to read a website exactly the same. However, when I run my script in headless it fails because it can't find certain elements (I'm using xpath). I checked the source code that selenium captures using both options and it's exactly the same. However, elements that I'm using from Inspect Element are not in the source code for either so I'm assuming source code does not matter?
When using headless, selenium cannot find a scroller and a button which I'm trying to interact with.
Error:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Options
# I'm using the below to execute the driver.
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument("--headless")
#options.add_argument("window-size=1400,600") I've tried with this as well
options.add_argument("User-Agent': 'USER_AGENT = User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'")
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
driver.get("https://website.com")
Any advice or suggestions on troubleshooting further?