Selene and Appium – how to make them work?
Currently if you use
from selene.support.shared import browser
browser.config.driver = yourAppiumDriver
...
it will fail with something like:
self.browser_name = value and value.name # overwrites default browser_name
File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 215, in name
raise KeyError('browserName not specified in session capabilities')
KeyError: 'browserName not specified in session capabilities'
For now it's unclear should we fix the "shared browser" in Selene or not... Maybe it's good to keep it as it is, i.e. web-ui oriented, not web+mobile oriented... We'll see...
But now, the core API of selene should work:
from selene import Browser, Config
mobile = Browser(Config(
driver=yourAppiumDriver,
timeout=10,
...))
# ...
But now, the core API of selene should work:
from selene import Browser, Config mobile = Browser(Config( driver=yourAppiumDriver, timeout=10, ...))
So then u should throw mobile to each test as a fixture, and call
mobile.element(..)?
you can manage your mobile instance in a whatever way you like. Just keep it as a global variable and import where do you need it
# tests/conftest.py
from selene import Browser, Config
mobile = Browser(Config(
driver=yourAppiumDriver,
timeout=10,
...))
# tests/test_app.py
from tests.conftest import mobile
def test_something():
mobile. ...
or use it as an explicit fixture:
# tests/conftest.py
from selene import Browser, Config
import pytest
# here it is implemented yet as a global variable, but you can change implementation to create it in the fixture below each time...
mobile_browser = Browser(Config(
driver=yourAppiumDriver,
timeout=10,
...))
@pytest.fixture
def mobile()
return mobile_browser
# tests/test_app.py
def test_something(mobile):
mobile. ...
@yashaka understood. Thank you!
Example of project with configured Appium + Selene - https://github.com/qa-guru/mobile-tests-13-py