AppDaemon with Selenium

Hi All,

I am attempting to run a python script that craws a website for my smart oil guage. The script works without issue on my local computer but will not run under AppDaemon. Is the below something that AppDaemon can support?

Thank you.

import appdaemon.plugins.hass.hassapi as hass

class oil(hass.Hass):

    def initialize(self):
        self.listen_event(self.check_oil, "check_oil")


    def check_oil(self, event_name, data, kwargs):

        self.log("Checking Oil Level")
        from selenium import webdriver
        import paho.mqtt.publish as publish
        from pyvirtualdisplay import Display

        display = Display(visible=0, size=(1440, 900))
        display.start()

        browser = webdriver.Chrome('chrome')

        browser.set_window_size(1440, 900)

        browser.get("https://app.smartoilgauge.com/app.php")
        browser.find_element_by_id("inputUsername").send_keys("redacted")
        browser.find_element_by_id("inputPassword").send_keys("redacted")
        browser.find_element_by_css_selector("button.btn").click()
        browser.implicitly_wait(3)

        current_level = browser.find_element_by_xpath('//*[@id="tankFillDiv"]/div[3]').get_attribute("innerHTML")
        current_level_value = current_level.split(" ")
        browser.quit()
        self.log(current_level_value[0])
        print(current_level_value[0])
        publish.single("oilgauge/tanklevel", current_level_value[0], hostname="192.168.1.100", port=1883,
                       auth={'username': "redacted", 'password': "redacted"})

        display.stop()


Error

2021-01-30 20:23:41.815393 WARNING oil: ------------------------------------------------------------
2021-01-30 20:23:41.814699 WARNING oil: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chrome'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 933, in worker
    funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/oil.py", line 19, in check_oil
    browser = webdriver.Chrome('chrome')
  File "/usr/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chrome' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


2021-01-30 20:23:41.811232 WARNING oil: ------------------------------------------------------------
2021-01-30 20:23:41.810510 WARNING oil: Worker Ags: {'id': 'b1c649204eba47758d84af589d91b3b1', 'name': 'oil', 'objectid': '57d590300b0646cfaa9510e37aa3e1f1', 'type': 'event', 'event': 'check_oil', 'function': >, 'data': {}, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'__thread_id': 'thread-0'}}
2021-01-30 20:23:41.809167 WARNING oil: Unexpected error in worker for App oil:
2021-01-30 20:23:41.807836 WARNING oil: ------------------------------------------------------------

Hi, were you able to get this working? I too want to be able to use selenium in appdaemon!