Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPA.Browser.Selenium doesn't detect conda-forge Firefox binary #516

Closed
4 tasks
cmin764 opened this issue May 23, 2022 · 2 comments
Closed
4 tasks

RPA.Browser.Selenium doesn't detect conda-forge Firefox binary #516

cmin764 opened this issue May 23, 2022 · 2 comments
Assignees
Labels
bug Bad or unexpected behaviour wontfix This won't or can't be worked on

Comments

@cmin764
Copy link
Member

cmin764 commented May 23, 2022

Using a robot keyword like Selenium.Open Available Browser https://www.google.com browser_selection=firefox won't work under a Firefox-ready conda.yaml like:

channels:
  # Define conda channels here.
  - conda-forge

dependencies:
  # Define conda packages here.
  # If available, always prefer the conda version of a package, installation will be faster and more efficient.
  # https://anaconda.org/search
  - python=3.7.5
  - firefox=100.0
  - geckodriver=0.30.0

  - pip=20.1
  - pip:
      # Define pip packages here.
      # https://pypi.org/
      - rpaframework==14.1.0 # https://rpaframework.org/releasenotes.html

since for some reason firefox binary isn't found in PATH but geckodriver works without setting it explicitly during the capabilities/options setting of the webdriver.

Solution

Tested with this robot:

Test Firefox
    # Using their keyword.
    Selenium.Open Firefox Site    https://www.google.com

    # Using our own RPA keyword.
    Selenium.Open Available Browser    https://www.google.com    headless=${HEADLESS}
    ...    browser_selection=firefox

and both of the calls work correctly now on a Mac. (problem doesn't replicate on Windows)

Therefore might be fixed with a patch like this:

    @staticmethod
    def _set_firefox_binary(options):
        if "win32" in sys.platform:
            return
        
        # On *nix systems Firefox binary path still needs to be explicitly set.
        for path in os.getenv("PATH").strip().split(":"):
            if fnmatch.fnmatch(path, "*/holotree/*/bin"):
                # We just found the path containing firefox and geckodriver binaries.
                break
        else:
            raise Exception("Holotree path not found: please run with rcc/VSCode")
        
        options.binary_location = f"{path}/firefox"
    
    def _get_driver_args(self, browser, *args, **kwargs):
        # This is used with the `Open Available Browser` keyword.
        driver_args = super()._get_driver_args(browser, *args, **kwargs)
        if "firefox" in browser.lower():
            self._set_firefox_binary(driver_args[0]["options"])
        return driver_args

in our RPA.Browser.Selenium library. (tested and working on both Mac and Windows)

ToDo:

  • Investigate additionally this problem: WebDriverException: Message: Can not connect to the Service /Users/cmin/.robocorp/holotree/b1f3c244e_9ba66f27/bin/firefox (timebox it to half a day)
  • PR with this or similar patch fixing the issue with running Firefox browser on Mac/Linux
  • Additional tests in Control Room with: Linux container & custom env on a LightSail Windows 10 instance
  • Optional unit & robot tests to test the patching triggering on firefox webdrivers
@cmin764 cmin764 added bug Bad or unexpected behaviour enhancement Improve an existing feature labels May 23, 2022
@cmin764 cmin764 added this to Pending in RPA Framework via automation May 23, 2022
@bogdancondurache
Copy link
Contributor

@cmin764 this seems to be an issue with Selenium: SeleniumHQ/selenium#10686
Should we close this issue on our side and wait for it to get solved or just keep it in the backlog for tracking purposes?

@cmin764 cmin764 added wontfix This won't or can't be worked on and removed enhancement Improve an existing feature labels May 24, 2022
@cmin764
Copy link
Member Author

cmin764 commented May 24, 2022

I'm closing it as not planned. (won't fix on our side, since should be on their's)

And for tracking purposes, we'll always have it on our "graveyard" and can be re-opened later on if it becomes something we need to fix on our side.

@cmin764 cmin764 closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
RPA Framework automation moved this from Pending to Done May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bad or unexpected behaviour wontfix This won't or can't be worked on
Projects
Development

No branches or pull requests

2 participants