dangoldin / yahoo-ffl

Yahoo Fantasy Football Stats
MIT License
31 stars 9 forks source link

NoSuchElementException during login() #2

Closed mikewojnowicz closed 6 years ago

mikewojnowicz commented 6 years ago

Hey Dan,

Very excited to see this repo! (Also, btw, fellow Cornell alum here :)

Tried using it tonight, ran into a problem. Wondering if you could help. Please excuse the fact that this is my first exposure to selenium and web scraping.

I created a settings.py as follows:

YAHOO_USERNAME = /redacted_string_here/ YAHOO_PASSWORD = /redacted_string_here/ YAHOO_LEAGUEID = /redacted_string_here/

When stepping through the lines of login(), this line:

driver.get("http://football.fantasysports.yahoo.com/f1/{0}".format(settings.YAHOO_LEAGUEID))

runs without complaint,

but the next line:

username = driver.find_element_by_name('username')

produces a NoSuchElementException, as cut and paste below.

I'm wondering if Yahoo changed their login procedure such that the code in this repo is no longer valid, or if perhaps I'm doing something wrong (and if so, if there's anything you could recommend to proceed further.)

In [14]: username = driver.find_element_by_name('username')

NoSuchElementException Traceback (most recent call last)

in () ----> 1 username = driver.find_element_by_name('username') /Users/redacted_string_here/Repos/yahoo-ffl/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in find_element_by_name(self, name) 300 driver.find_element_by_name('foo') 301 """ --> 302 return self.find_element(by=By.NAME, value=name) 303 304 def find_elements_by_name(self, name): /Users/redacted_string_here/Repos/yahoo-ffl/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in find_element(self, by, value) 660 661 return self.execute(Command.FIND_ELEMENT, --> 662 {'using': by, 'value': value})['value'] 663 664 def find_elements(self, by=By.ID, value=None): /Users/redacted_string_here/Repos/yahoo-ffl/env/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc in execute(self, driver_command, params) 171 response = self.command_executor.execute(driver_command, params) 172 if response: --> 173 self.error_handler.check_response(response) 174 response['value'] = self._unwrap_value( 175 response.get('value', None)) /Users/redacted_string_here/Repos/yahoo-ffl/env/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.pyc in check_response(self, response) 162 if exception_class == ErrorInResponseException: 163 raise exception_class(response, message) --> 164 raise exception_class(message, screen, stacktrace) 165 166 def _value_or_default(self, obj, key, default): NoSuchElementException: Message: u'no such element: Unable to locate element: {"method":"name","selector":"username"}\n (Session info: chrome=60.0.3112.113)\n (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.3 x86_64)'
dangoldin commented 6 years ago

Hmm - I just tried running it and works fine for me so I wonder if they have multiple login flows. What flow do you see when you try it? You can inspect the source code and see what they have as the element for the username field.

mikewojnowicz commented 6 years ago

Ah, dang, you're right. The problem, it turns out, is that I was using my League name as the YAHOO_LEAGUEID in settings.py. I didn't realize there was a numerical identifier as well. Thanks :)