jantman / xfinity-usage

Python/selenium script to get Xfinity bandwidth usage
GNU Affero General Public License v3.0
66 stars 18 forks source link

Problem running, getting no attribute 'browser' #13

Closed pkellner closed 6 years ago

pkellner commented 6 years ago

Sorry for the post here because this is really me not understanding python likely.

I tried both python 2.7 and 3 and in both cases got the same error (pasted below). I'm windows 10. Anything obvious I'm doing wrong?

c:\python27\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless ' Traceback (most recent call last): File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "c:\python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "C:\Python27\Scripts\xfinity-usage.exe__main__.py", line 9, in File "c:\python27\lib\site-packages\xfinity_usage\xfinity_usage.py", line 612, in main res = script.run() File "c:\python27\lib\site-packages\xfinity_usage\xfinity_usage.py", line 124, in run self.browser.quit() AttributeError: 'XfinityUsage' object has no attribute 'browser' PS C:\temp\xfinity-usage-master\xfinity-usage-master>

jantman commented 6 years ago

@pkellner I haven't used Windows in ages and don't have access to it, so I can't confirm or test anything Windows-specific. However...

The important part of the error message you're getting is, "Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead".

By default (you can confirm this with xfinity-usage -h), xfinity-usage attempts to use PhantomJS to retrieve the Xfinity website. Apparently Selenium no longer supports PhantomJS. Your options, as far as I can think, are as follows:

  1. If you have a working PhantomJS installation on your system, you can downgrade your Python selenium version to one that still supports PhantomJS.
  2. Install Google Chrome or Chromium and chromedriver and use that, by passing xfinity-usage the -b chrome-headless option.
  3. Install Mozilla Firefox and geckodriver and use that, by passing xfinity-usage the -b firefox option.
jantman commented 6 years ago

@pkellner did any of those work for you?

marcosw1 commented 6 years ago

I installed chromedriver and was using the -b chrome-headless option but was seeing the same error as the original poster. The problem was that the chromdriver binary was not being found. Adding /usr/lib/chromium-browser to my path fixed it.

The try/except starting at line 117 in xfinity_usage.py was masking the error message, when I removed the try and ran the code I received this error:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

which made the the problem obvious.

BTW, Comcast has made some changes to their website, the remember_me element referenced in line 150 of xfinity_usage.py needs to be change to remember_me_checkbox. The program works without that change, it just spews a bunch of messages on the screen before producing the correct usage information.

Thanks for writing a useful program, I was planning on writing my own usage checker when I ran across yours.

jantman commented 6 years ago

@marcosw1 Thanks so much for updating with all of that. I've got the confusing exception/traceback as well as the checkbox issue (which seems to be an issue with chrome-headless and layering of elements). Would you like to test the fixes before I cut a new release? Both seem to be working for me.

jantman commented 6 years ago

@marcosw1 I've merged my #13 which makes these fixes, and released it as 2.0.2. That seems to fix the problem for me. If you have further issues, please feel free to reopen this.