Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions appium/webdriver/appium_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
import re
import shutil
import subprocess as sp
import sys
import time
Expand Down Expand Up @@ -225,21 +226,7 @@ def is_service_listening(url: str, timeout: float = 5, custom_validator: Callabl


def find_executable(executable: str) -> str | None:
path = os.environ['PATH']
paths = path.split(os.pathsep)
_, ext = os.path.splitext(executable)
if sys.platform == 'win32' and not ext:
executable = executable + '.exe'

if os.path.isfile(executable):
return executable

for p in paths:
full_path = os.path.join(p, executable)
if os.path.isfile(full_path):
return full_path

return None
return shutil.which(executable)


def get_node() -> str:
Expand Down
8 changes: 8 additions & 0 deletions test/unit/webdriver/appium_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class TestAppiumService:
def test_get_instance(self):
assert AppiumService()

def test_find_executable_found(self, monkeypatch):
monkeypatch.setattr(appium_service.shutil, 'which', lambda cmd: f'/usr/bin/{cmd}')
assert appium_service.find_executable('node') == '/usr/bin/node'

def test_find_executable_not_found(self, monkeypatch):
monkeypatch.setattr(appium_service.shutil, 'which', lambda cmd: None)
assert appium_service.find_executable('non_existent_exe') is None

@pytest.mark.parametrize(
('status', 'expected_result', 'expected_elapsed', 'expected_requests'),
[(200, True, 0.0, 1), (503, False, 5.0, 10)],
Expand Down
Loading