helium icon indicating copy to clipboard operation
helium copied to clipboard

Support renamed Chrome.app on macOS

Open finngaida opened this issue 3 years ago • 1 comments

I got an error when launching helium via driver = start_chrome():

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

After some trial and error I noticed Chrome gets installed into /Applications/Google Chrome.app by default, however I had renamed it to just Chrome.app, presumably breaking the binary lookup functionality of helium. It was easily fixed by linking Chrome to the expexted path via ln -s /Applications/Chrome.app /Applications/Google\ Chrome.app -however an API access à la driver = start_chrome(binary_path="/Applications/Chome.app") would be preferable.

finngaida avatar Aug 13 '22 09:08 finngaida

Cursor_and_Google

I'm on macos too... and when I run the example script I first have to accept cookies. I hacked the code to wait a bit like this..

import helium
from time import sleep
# See: https://github.com/mherrmann/helium/blob/master/docs/cheatsheet.md

print(dir(helium))

print("Starting chrome...")
helium.start_chrome('google.com')
sleep(5)
print("Continuing... searching for helium")
helium.write('helium selenium github')
helium.press(helium.ENTER)
helium.click('mherrmann/helium')
helium.go_to('github.com/login')
helium.write('username', into='Username')
helium.write('password', into='Password')
helium.click('Sign in')
helium.kill_browser()

Then... it errors like this...

  File "/Users/tas509/helium_chrome/example.py", line 13, in <module>
    helium.click('mherrmann/helium')
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/__init__.py", line 280, in click
    _get_api_impl().click_impl(element)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 177, in click_impl
    self._perform_mouse_action(element, self._click)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 36, in f_decorated
    result = f(self, *args, **kwargs)
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 55, in f_decorated
    return f(*args, **kwargs)
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 219, in _perform_mouse_action
    self._manipulate(element, lambda wew: action(wew.unwrap(), offset))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 285, in _manipulate
    driver.last_manipulated_element = gui_or_web_elt.perform(action)
                                      ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/Users/tas509/helium_chrome/env/lib/python3.13/site-packages/helium/_impl/__init__.py", line 641, in perform
    raise LookupError()
LookupError

everythingability avatar Dec 12 '24 11:12 everythingability