I tried automating the below code with headful mode and it works but not in headless mode. Throws a lot of javascript errors and finally says unable to find the element.