gilesknap / maaspower

Provide MAAS power control via webhooks for various remote control power switches.
Apache License 2.0
18 stars 13 forks source link

Selenium Error #15

Closed apowers313 closed 1 year ago

apowers313 commented 1 year ago

Environment:

Looks like maaspower chokes while trying to start up on the line self.c_driver = webdriver.Chrome(self.driver, options=options) in web_ui.py. Any thoughts on how to go about debugging this?

$ sudo bin/maaspower run maaspower.cfg
Traceback (most recent call last):

  File "/home/apowers/maaspower/bin/maaspower", line 8, in <module>
    sys.exit(cli())

  File "/home/apowers/maaspower/lib/python3.10/site-packages/maaspower/__main__.py", line 64, in run
    maas_globals.maas_config = MaasConfig.deserialize(config_dict)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/maaspower/maasconfig.py", line 139, in deserialize
    config: Any = deserialize(cls, d)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/apischema/deserialization/__init__.py", line 887, in deserialize
    return deserialization_method(

  File "apischema/deserialization/methods.pyx", line 504, in apischema.deserialization.methods.ObjectMethod.deserialize

  File "apischema/deserialization/methods.pyx", line 505, in apischema.deserialization.methods.ObjectMethod.deserialize

  File "apischema/deserialization/methods.pyx", line 958, in apischema.deserialization.methods.ObjectMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1291, in apischema.deserialization.methods.DeserializationMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 847, in apischema.deserialization.methods.ListMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1339, in apischema.deserialization.methods.DeserializationMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1189, in apischema.deserialization.methods.ConversionUnionMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1307, in apischema.deserialization.methods.DeserializationMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1078, in apischema.deserialization.methods.ObjectMethod_deserialize

  File "apischema/deserialization/methods.pyx", line 1348, in apischema.deserialization.methods.Constructor_construct

  File "apischema/deserialization/methods.pyx", line 1227, in apischema.deserialization.methods.RawConstructor_construct

  File "<string>", line 16, in __init__

  File "/home/apowers/maaspower/lib/python3.10/site-packages/maaspower/devices/web_ui.py", line 48, in __post_init__
    self.connect()

  File "/home/apowers/maaspower/lib/python3.10/site-packages/maaspower/devices/web_ui.py", line 56, in connect
    self.c_driver = webdriver.Chrome(self.driver, options=options)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 80, in __init__
    super().__init__(

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 104, in __init__
    super().__init__(

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)

  File "/home/apowers/maaspower/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x5630ddcb7243 <unknown>
#1 0x5630dda7b7a6 <unknown>
#2 0x5630ddaa4520 <unknown>
#3 0x5630ddaa049b <unknown>
#4 0x5630ddae22a7 <unknown>
#5 0x5630ddae18cf <unknown>
#6 0x5630ddad8e53 <unknown>
#7 0x5630ddaab9ea <unknown>
#8 0x5630ddaacb2e <unknown>
#9 0x5630ddd0bd5e <unknown>
#10 0x5630ddd0fa80 <unknown>
#11 0x5630ddcf18b0 <unknown>
#12 0x5630ddd10b63 <unknown>
#13 0x5630ddce2f75 <unknown>
#14 0x5630ddd33998 <unknown>
#15 0x5630ddd33b27 <unknown>
#16 0x5630ddd4ec23 <unknown>
#17 0x7f982e5c8b43 <unknown>
gilesknap commented 1 year ago

I'll have to fire this project up again on the weekend and see if I can reproduce this. in the mean time does this help at all https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t

One difference between your environ and mine is that I'm using Ubuntu workstation. I assume you can run Chrome OK standalone on your server ? or is it headless - if so that could be an issue.

apowers313 commented 1 year ago

Installed Ubuntu Desktop and started maaspower from userland -- looks like I'm up and running!

How can I buy you a pint?

gilesknap commented 1 year ago

That's great. This is because selenium is driving an actual chrome instance with hidden window, its not ideal but its the only way to configure many such switches that don't supply an API for configuration.

No need for a pint, I make FOSS because its fun (you could star the project if you feel so inclined :-) )