tdameritrade icon indicating copy to clipboard operation
tdameritrade copied to clipboard

headless chromedriver?

Open anishzute opened this issue 4 years ago • 4 comments

Out of curiosity, is there a way to have the authentication method run entirely headless if username and password parameters are passed so that it can be used on things such as servers and google colab without modification? I have currently modified the auth/init.py to include the following:

    from selenium import webdriver
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    chrome_driver_binary = which('chromedriver') or "/usr/lib/chromium-browser/chromedriver"
    driver = webdriver.Chrome('chromedriver', options=options)

however I don't know if this would work on other operating systems and implementations.

anishzute avatar May 04 '20 19:05 anishzute

@anishzute Im not certain about how the --headless flag is handled on every OS but it seems at least on OSX and Ubuntu It has worked for me. Also I have a PR open that handles automating the entire Auth flow. It will default to a headless selenium instance. See code

ka05 avatar May 05 '20 03:05 ka05

Nice! I'm currently working on Ubuntu off a forked repo where I've incorporated the headless flag, but it's always a pain to deal with local chromedriver and all that, especially because I tend to do a lot of my quick scripting/prototyping in Google Colab/Jupyter. I'm hoping your auth method gets merged as it seems much more straightforward and it would be nice to have 2 factor support. Regardless, I'll copy over your code and give it a go. Thanks!

anishzute avatar May 07 '20 07:05 anishzute

I went ahead and merged into dev branch.

We don't have tests running on that yet. @timkpaine can we update the azure-pipeline.yml to trigger on dev also? Not sure what 2nd order effects that would have.

dahifi avatar May 12 '20 01:05 dahifi

yep just add it to the list of triggers in the pipelines file

timkpaine avatar Jun 15 '20 15:06 timkpaine