python-client icon indicating copy to clipboard operation
python-client copied to clipboard

python+uiautomator2: URI and package arguments are required

Open joudinet opened this issue 2 years ago • 1 comments

Do I have the most recent component updates?

  • [X] I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • [X] I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

I cannot find how to use the uiautomator2 driver to launch a browser to get to a specific webpage.

Expected Behavior

Launch the chrome browser on the android virtual device and go to the URL https://webkit.org/status

Minimal Reproducible Example

Example code in python that fails with the following error message: URI and package arguments are required

import pytest
from appium import webdriver
# Options are available in Python client since v2.6.0
from appium.options.android import UiAutomator2Options

def generate_options():
    common_caps = {
        'appium:avd': 'Pixel_3a_API_34_extension_level_7_x86_64',
    }
    chrome_options = UiAutomator2Options().load_capabilities(common_caps)
    chrome_options.browserName = 'chrome'
    return [chrome_options]

@pytest.fixture(params=generate_options())
def driver(request):
    # The default URL is http://127.0.0.1:4723/wd/hub in Appium1
    drv = webdriver.Remote('http://localhost:4723', options=request.param)
    yield drv
    drv.quit()

def test_foo(driver):
    driver.get('https://webkit.org/status')

Environment

  • Operating system: Linux
  • Appium server version (output of appium --version): 2.1.3
  • Appium driver(s) and their version(s): [email protected] [installed (npm)]
  • Appium plugin(s) and their version(s):
  • Node.js version (output of node --version): v20.8.0
  • npm version (output of npm --version): 10.2.0
  • Last component(s) version which did not exhibit the problem:
  • Platform and version under test: android
  • Real device or emulator/simulator: emulator

Link to Appium Logs

No response

Further Information

No response

joudinet avatar Oct 13 '23 16:10 joudinet

Please attach the full appium log. https://discuss.appium.io/ would help to ask such questions as well

KazuCocoa avatar Oct 13 '23 17:10 KazuCocoa

@joudinet, Have you checked https://github.com/appium/python-client/blob/master/test/functional/android/chrome_tests.py?

Dor-bl avatar Jun 19 '24 11:06 Dor-bl

Sorry, I completely forgot about this issue, which I solved long ago. I unfortunately do not remember exactly what solves this issue but I'm using the AppiumOptions from appium.options.common instead of UiAutomator2Options from appium.options.android, like in the example cited by @Dor-bl.

joudinet avatar Jun 21 '24 15:06 joudinet