Install firefox in a published app for Selenium

We want to use Selenium in one of our apps. Locally I have everything working via the code below. The webdriver_manager should install the Gecko render engine but the firefox GUI also seems to be used on my laptop. When I publish the app I get the execution error:

selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no ‘moz:firefoxOptions.binary’ capability provided, and no binary flag set on the command line

Next, I tried installing firefox in the published app by adding packages = ["firefox"] to my viktor toml file. However, during publishing I get the error:

ERROR packing completed with errors: Could not install all packages:
Reading package lists…
Building dependency tree…
Reading state information…
Package firefox is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘firefox’ has no installation candidate

Can somebody help me with getting it to work in a published viktor app?

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager

temp_html_file = os.path.join(tempfile.gettempdir(), "map.html")

options = Options()
options.add_argument("--headless")  # Run in headless mode
# options.headless = True

# Set up the Selenium WebDriver with Firefox
service = Service(GeckoDriverManager().install())
driver = webdriver.Firefox(service=service, options=options)

# Open the local HTML file
driver.get(f"file:///{temp_html_file}")  # Replace with your file path
map_path = os.path.join(tempfile.gettempdir(), "map.png")

# Take a screenshot and save it
driver.get_screenshot_as_file(map_path)

# Clean up and close the browser
driver.quit()

Hi @Vincentvd ,

I doubt that using selenium within the VIKTOR app environment will be possible. Could you elaborate what you would like to achieve specifically? I see that there are references to creating a screenshot of a map to convert to an image. Maybe these posts may be applicable?

Well we use leafmap/Folium to create our maps in Viktor because it has much more options compared to the Viktor mapview. We now want to export the map as image and add it to a PDF report.

I have also thought of the solutions you proposed but I fear that we some leafmap features like WMS layers that plotly does not support. It would also mean that we would have to maintain 2 systems to create our maps because we will need leafmap as result view in Viktor.

But why don’t you think that the VIKTOR app environment doesn’t support selenium?

edit: According to your docs, you can install apt-get comptatible apps so I expected the firefox installation to work