![]() |
|
[Python] [Selenium/python] Help running headless with Chrome profile - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] [Selenium/python] Help running headless with Chrome profile (/showthread.php?tid=6136242) |
[Selenium/python] Help running headless with Chrome profile - jmartle - Jan 25, 2021 Code options = webdriver.ChromeOptions()If i run it without headless, with my browser open, everything works good. the Chrome profile works and the selenium script runs well. but if i try to go headless, i get error. pls help i am noob Code selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@type='file']"}RE: [Selenium/python] Help running headless with Chrome profile - ๖ۣۜNyanbot - Jan 25, 2021 Might be loading the page too fast. Try looking into this. https://selenium-python.readthedocs.io/waits.html RE: [Selenium/python] Help running headless with Chrome profile - Nomad.Null - Jan 26, 2021 Just like Nyan said, you need to wait for the page to load either with a delay (dirty) or you should wait for the specific element you want: PHP Code The "element_condition" can be the element itself that you're looking for once it appears on the page, or you can use an "expected condition" from the "selenium.webdriver.support.expected_conditions". There are several you can use. I use this for a LinkedIn scraper, just as an example, and it works great. |