Scenario:
I'm attempting to ADB connect to an android phone as part of an automation framework test by using shell commands in os.popen(), I am able to connect but 'adb devices' returns the device as connected but unauthorized, example code:
def test_connect_phone(self, phone):
connect_stream = os.popen(f'adb connect {phone.host}:{phone.port}')
print(connect_stream.read())
install_stream = os.popen('adb devices')
output = install_stream.read()
print(output)
assert output
# output
connected to <HOST>:<PORT>
List of devices attached
<HOST>:<PORT> unauthorized
Running the same commands directly from the terminal works and the device is authorized:
adb connect <HOST>:<PORT>
adb devices
#output
connected to <HOST>:<PORT>
List of devices attached
<HOST>:<PORT> device
Note: I am using tox for pytest which made me think it could be an environment issue, but in testing I see during runtime my home dir remains the same.
Any help is appreciated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…