所需的功能和驱动程序实现:
@pytest.fixture
def driver(request):
print(os.getcwd())
global driver
caps = {}
caps = {
'automationName': 'XCUITest',
'platformName': 'iOS',
'deviceName': 'iPhone 6S',
'platformVersion': '16.6',
'udid': '******',
'autoAcceptAlerts': 'true',
'noReset': False,
'fullReset': False,
'app': os.getcwd() + '/app/apkname.ipa'
}
appium_server_url = "http://localhost:4723/wd/hub"
driver = webdriver.Remote(appium_server_url, caps)
yield driver
控制台日志:
tests/step_defs/framework/driver.py:45: in driver
driver = webdriver.Remote(appium_server_url, caps)
my_env/lib/python3.11/site-packages/appium/webdriver/webdriver.py:229: in __init__
super().__init__(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x10cc97710>, command_executor = <appium.webdriver.appium_connection.AppiumConnection object at 0x10cc97650>, keep_alive = True
file_detector = None, options = None
def __init__(
self,
command_executor="http://127.0.0.1:4444",
keep_alive=True,
file_detector=None,
options: Union[BaseOptions, List[BaseOptions]] = None,
) -> None:
"""Create a new driver that will issue commands using the wire
protocol.
:Args:
- command_executor - Either a string representing URL of the remote server or a custom
remote_connection.RemoteConnection object. Defaults to 'http://127.0.0.1:4444/wd/hub'.
- keep_alive - Whether to configure remote_connection.RemoteConnection to use
HTTP keep-alive. Defaults to True.
- file_detector - Pass custom file detector object during instantiation. If None,
then default LocalFileDetector() will be used.
- options - instance of a driver options.Options class
"""
if isinstance(options, list):
capabilities = create_matches(options)
_ignore_local_proxy = False
else:
> capabilities = options.to_capabilities()
E AttributeError: 'NoneType' object has no attribute 'to_capabilities'
my_env/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:185: AttributeError
================================================================================================================ warnings summary =================================================================================================================
my_env/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py:27
预期脚本应成功运行,并且appium服务器GUI将显示执行日志
2条答案
按热度按时间uidvcgyl1#
例如,尝试传递
options
3j86kqsm2#
我同意最后的评论。问题出在3.0.0版。