多個 py 檔案,放在一個指令碼中執行,使用 TestSuite,怎樣才能只執行一次 setUp ( 已經使用了 @classmethod ) ?
有3個py檔案,FooTest_Case1.py,FooTest_Case2.py,FooTest_Case3.py。新建了一個 FooTest_AllCase.py,將前面的三個檔案使用TestSuite放在這裡面。在FooTest_AllCase.py中,setUp 和 tearDown 均加了裝飾器 @classmethod。我的預期是在執行所有case之前只執行一次 setUp,所有case結束後現在有兩個問題:
- 實際執行中,在每條用例完成之後會執行 tearDown,下條用例執行之前都會執行 setUp,和預期不符;
- 最後一條用例結束後沒有執行 tearDown,但是指令碼還是正常的結束了
這兩點希望有人可以幫忙解答,謝謝
程式碼很簡單,如下所示:
FooTest_Case1.py:
from appium import webdriver
import unittest
import time, os
from selenium.webdriver.support.ui import WebDriverWait
class FooTest_Case_1(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.system("adb shell input keyevent 26")
os.system("adb shell input keyevent 3")
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9' #Pixel 2
desired_caps['deviceName'] = 'FA7971A04040' #Pixel 2
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = 'com.android.settings.Settings'
desired_caps['newCommandTimeout'] = '3000'
cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# test_case_1: 檢查飛航模式是否開啟
def test_case_1(self):
self.driver.find_element_by_name("網路和網際網路").click()
textFly = self.driver.find_element_by_id("android:id/switch_widget").get_attribute("text")
if textFly == "開啟":
print("飛航模式已開啟")
elif textFly == "關閉":
print("飛航模式已關閉")
print("test_case_1 --------------------")
time.sleep(3)
os.system('adb shell input keyevent 4')
@classmethod
def tearDownClass(cls):
cls.driver.keyevent(26)
cls.driver.quit()
if __name__ == '__main__':
unittest.main()
FooTest_Case2.py:
from appium import webdriver
import unittest
import time, os
from selenium.webdriver.support.ui import WebDriverWait
class FooTest_Case_2(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.system("adb shell input keyevent 26")
os.system("adb shell input keyevent 3")
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9' #Pixel 2
desired_caps['deviceName'] = 'FA7971A04040' #Pixel 2
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = 'com.android.settings.Settings'
desired_caps['newCommandTimeout'] = '3000'
cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# test_case_2: 檢查藍芽是否開啟
def test_case_2(self):
self.driver.find_element_by_name("已連線的裝置").click()
self.driver.find_element_by_android_uiautomator('new UiSelector().text("連線偏好設定")').click()
self.driver.find_element_by_name("藍芽").click()
bt = self.driver.find_element_by_id("com.android.settings:id/switch_widget").get_attribute('checked')
if bt == 'true':
print("藍芽已開啟")
elif bt == 'false':
print("藍芽已關閉")
print("test_case_2 ....................")
time.sleep(3)
os.system('adb shell input keyevent 4')
os.system('adb shell input keyevent 4')
os.system('adb shell input keyevent 4')
if __name__ == '__main__':
unittest.main()
FooTest_Case3.py:
from appium import webdriver
import unittest
import time, os
from selenium.webdriver.support.ui import WebDriverWait
class FooTest_Case_3(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.system("adb shell input keyevent 26")
os.system("adb shell input keyevent 3")
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9' #Pixel 2
desired_caps['deviceName'] = 'FA7971A04040' #Pixel 2
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = 'com.android.settings.Settings'
desired_caps['newCommandTimeout'] = '3000'
cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# test_case_3: 檢查wifi是否開啟
def test_case_3(self):
self.driver.find_element_by_name("網路和網際網路").click()
self.driver.find_element_by_android_uiautomator('new UiSelector().text("WLAN")').click()
wifi = self.driver.find_element_by_id("com.android.settings:id/switch_widget").get_attribute('checked')
if wifi == 'true':
print('WiFi 已開啟')
else:
print('WiFi 已關閉')
print("test_case_3 ********************")
time.sleep(3)
os.system('adb shell input keyevent 4 && adb shell input keyevent 4')
@classmethod
def tearDownClass(cls):
cls.driver.keyevent(26) #作用等同於上句呼叫adb,滅屏
cls.driver.quit()
if __name__ == '__main__':
unittest.main()
FooTest_AllCase.py
from appium import webdriver
import unittest
import time, os
from selenium.webdriver.support.ui import WebDriverWait
from FooTest_Case1 import FooTest_Case_1
from FooTest_Case2 import FooTest_Case_2
from FooTest_Case3 import FooTest_Case_3
class FooTest_All_Case(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.system("adb shell input keyevent 26")
os.system("adb shell input keyevent 3")
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9' #Pixel 2
desired_caps['deviceName'] = 'FA7971A04040' #Pixel 2
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = 'com.android.settings.Settings'
desired_caps['newCommandTimeout'] = '3000'
cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
@classmethod
def tearDownClass(cls):
cls.driver.keyevent(26)
cls.driver.quit()
if __name__ == '__main__':
#unittest.main()
suite = unittest.TestSuite()
suite.addTest(FooTest_Case_3("test_case_3"))
suite.addTest(FooTest_Case_1("test_case_1"))
suite.addTest(FooTest_Case_2("test_case_2"))
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite)
Appium Log:
[BaseDriver] Event 'quitSessionFinished' logged at 1597195765635 (09:29:25 GMT+0800 (中國標準時間))
[W3C (8090ade4)] Received response: null
[W3C (8090ade4)] But deleting session, so not returning
[W3C (8090ade4)] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/8090ade4-8bc5-4bd3-9987-5742cc4ca7f7 200 1989 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:platformVersion":"9","appium:deviceName":"FA7971A04040","appium:appPackage":"com.android.settings","appium:appActivity":"com.android.settings.Settings","appium:newCommandTimeout":"3000"}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"9","deviceName":"FA7971A04040","appPackage":"com.android.settings","appActivity":"com.android.settings.Settings","newCommandTimeout":"3000"}}
[W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"9","deviceName":"FA7971A04040","appPackage":"com.android.settings","appActivity":"com.android.settings.Settings","newCommandTimeout":"3000"},null,{"firstMatch":[{"platformName":"Android","appium:platformVersion":"9","appium:deviceName":"FA7971A04040","appium:appPackage":"com.android.settings","appium:appActivity":"com.android.settings.Settings","appium:newCommandTimeout":"3000"}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1597195768048 (09:29:28 GMT+0800 (中國標準時間))
[BaseDriver] Number capability passed in as string. Functionality may be compromised.
[Appium]
[Appium] ======================================================================
[Appium] DEPRECATION WARNING:
[Appium]
[Appium] The 'automationName' capability was not provided in the desired
[Appium] capabilities for this Android session
[Appium]
[Appium] Setting 'automationName=UiAutomator1' by default and using the
[Appium] UiAutomator1 Driver
[Appium]
[Appium] The next minor version of Appium (1.14.x) will set
[Appium] 'automationName=UiAutomator2' by default and use the UiAutomator2
[Appium] Driver
[Appium]
[Appium] The next major version of Appium (2.x) will **require** the
[Appium] 'automationName' capability to be set for all sessions on all
[Appium] platforms
[Appium]
[Appium] If you are happy with 'UiAutomator1' and do not wish to upgrade
[Appium] Android drivers, please add 'automationName=UiAutomator1' to your
[Appium] desired capabilities
[Appium]
[Appium] For more information about drivers, please visit
[Appium] http://appium.io/docs/en/about-appium/intro/ and explore the
[Appium] 'Drivers' menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Setting automation to 'UiAutomator1'.
[Appium] Consider setting 'automationName' capability to 'UiAutomator2' on Android >= 6, since UIAutomator1 framework is not maintained anymore by the OS vendor.
[Appium] Appium v1.13.0 creating new AndroidDriver (v4.15.1) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] platformVersion: 9
[Appium] deviceName: FA7971A04040
[Appium] appPackage: com.android.settings
[Appium] appActivity: com.android.settings.Settings
[Appium] newCommandTimeout: 3000
[BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were provided
[BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Number capability passed in as string. Functionality may be compromised.
[BaseDriver] Capability 'newCommandTimeout' changed from string ('3000') to integer (3000). This may cause unexpected behavior
[BaseDriver] Session created with session id: 17effdf8-266d-4239-9edc-a5372dd5ad6b
[ADB] Using 'adb.exe' from 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '9'
[ADB] Setting device id to FA7971A04040
[ADB] Getting device platform version
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[AndroidDriver] Using device: FA7971A04040
[ADB] Using 'adb.exe' from 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe'
[ADB] Setting device id to FA7971A04040
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Device API level: 28
[AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[AndroidDriver] App file was not listed, instead we're going to run com.android.settings directly on the device
[AndroidDriver] Checking whether package is present on the device
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell pm list packages com.android.settings'
[AndroidDriver] Starting Android session
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 wait-for-device'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell dumpsys package io.appium.settings'
[ADB] Using 'aapt.exe' from 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\build-tools\29.0.3\aapt.exe'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('2.14.0' >= '2.14.0')
[ADB] There is no need to install/upgrade 'C:\Users\cody.ming\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Getting IDs of all 'io.appium.settings' processes
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell 'pgrep --help; echo $?''
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell pgrep -f io\\.appium\\.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell appops set io.appium.settings android\:mock_location allow'
[Logcat] Starting logcat capture
[ADB] Getting device platform version
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell wm size'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.product.model'
[ADB] Current device property 'ro.product.model': Pixel 2
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell getprop ro.product.manufacturer'
[ADB] Current device property 'ro.product.manufacturer': Google
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
[ADB] Getting install status for com.android.settings
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell dumpsys package com.android.settings'
[ADB] 'com.android.settings' is installed
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell am force-stop com.android.settings'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell pm clear com.android.settings'
[AndroidDriver] Performed fast reset on the installed 'com.android.settings' application (stop and clear)
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 forward tcp\:4724 tcp\:4724'
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell mkdir -p /data/local'
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 push C\:\\Users\\cody.ming\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\bootstrap\\bin\\AppiumBootstrap.jar /data/local/tmp/'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting IDs of all 'uiautomator' processes
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell pgrep -f uiautomator'
[ADB] No 'uiautomator' process has been found
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","FA7971A04040","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.android.settings","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell dumpsys window'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Running 'E:\Android_for_Appium\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -P 5037 -s FA7971A04040 shell am start -W -n com.android.settings/com.android.settings.Settings -S'
[Appium] New AndroidDriver session created successfully, session 17effdf8-266d-4239-9edc-a5372dd5ad6b added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1597195778217 (09:29:38 GMT+0800 (中國標準時間))
[W3C (17effdf8)] Cached the protocol value 'W3C' for the new session 17effdf8-266d-4239-9edc-a5372dd5ad6b
[W3C (17effdf8)] Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","platformVersion":"9","deviceName":"FA7971A04040","appPackage":"com.android.settings","appActivity":"com.android.settings.Settings","newCommandTimeout":3000},"platformName":"Android","platformVersion":"9","deviceName":"FA7971A04040","appPackage":"com.android.settings","appActivity":"com.android.settings.Settings","newCommandTimeout":3000,"deviceUDID":"FA7971A04040","deviceScreenSize":"1080x1920","deviceModel":"Pixel 2","deviceManufacturer":"Google"}}
[HTTP] <-- POST /wd/hub/session 200 10168 ms - 762
[HTTP]
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element
[HTTP] {"using":"name","value":"已連線的裝置"}
[W3C (17effdf8)] Calling AppiumDriver.findElement() with args: ["name","已連線的裝置","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"已連線的裝置","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"已連線的裝置","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '已連線的裝置' using 'NAME' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[DESCRIPTION=已連線的裝置, INSTANCE=0]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[TEXT=已連線的裝置, INSTANCE=0]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"1","ELEMENT":"1"}
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element 200 834 ms - 67
[HTTP]
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/1/click
[HTTP] {"id":"1"}
[W3C (17effdf8)] Calling AppiumDriver.click() with args: ["1","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/1/click 200 219 ms - 14
[HTTP]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element
[HTTP] {"using":"-android uiautomator","value":"new UiSelector().text(\"連線偏好設定\")"}
[W3C (17effdf8)] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().text(\"連線偏好設定\")","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().text(\"連線偏好設定\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().text(\"連線偏好設定\")","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().text("連線偏好設定")' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().text("連線偏好設定")
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "連線偏好設定"
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[TEXT=連線偏好設定]
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"2","ELEMENT":"2"}
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element 200 687 ms - 67
[HTTP]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"2"}}
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/2/click
[HTTP] {"id":"2"}
[W3C (17effdf8)] Calling AppiumDriver.click() with args: ["2","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/2/click 200 227 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element
[HTTP] {"using":"name","value":"藍芽"}
[W3C (17effdf8)] Calling AppiumDriver.findElement() with args: ["name","藍芽","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"藍芽","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"藍芽","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '藍芽' using 'NAME' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[DESCRIPTION=藍芽, INSTANCE=0]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[TEXT=藍芽, INSTANCE=0]
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"3","ELEMENT":"3"}
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element 200 793 ms - 67
[HTTP]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"3"}}
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/3/click
[HTTP] {"id":"3"}
[W3C (17effdf8)] Calling AppiumDriver.click() with args: ["3","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: click
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/3/click 200 222 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element
[HTTP] {"using":"id","value":"com.android.settings:id/switch_widget"}
[W3C (17effdf8)] Calling AppiumDriver.findElement() with args: ["id","com.android.settings:id/switch_widget","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator, name
[BaseDriver] Waiting up to 0 ms for condition
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.android.settings:id/switch_widget","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.android.settings:id/switch_widget","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.android.settings:id/switch_widget' using 'ID' with the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.android.settings:id/switch_widget]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"ELEMENT":"4"}}
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"4","ELEMENT":"4"}
[HTTP] <-- POST /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element 200 725 ms - 67
[HTTP]
[HTTP] --> GET /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/4/attribute/checked
[HTTP] {}
[W3C (17effdf8)] Calling AppiumDriver.getAttribute() with args: ["checked","4","17effdf8-266d-4239-9edc-a5372dd5ad6b"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:getAttribute","params":{"attribute":"checked","elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getAttribute","params":{"attribute":"checked","elementId":"4"}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getAttribute
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"true"}
[AndroidBootstrap] Received command result from bootstrap
[W3C (17effdf8)] Responding to client with driver.getAttribute() result: "true"
[HTTP] <-- GET /wd/hub/session/17effdf8-266d-4239-9edc-a5372dd5ad6b/element/4/attribute/checked 200 37 ms - 16
[HTTP]
CMD中的執行結果:
以上,謝謝!
相關文章
- mysql一次執行多個SQL檔案MySql
- PHP 使用檔案鎖 避免同時執行一個指令碼PHP指令碼
- python中怎樣執行指令碼Python指令碼
- 怎樣停止一個正在執行的執行緒執行緒
- selenium-grid 有多個節點,但 pytest.main 批次執行用例,每次只有一個節點執行用例,不能同時多個節點執行,要怎樣才能多個節點同時執行AI
- 指令碼執行 py 檔案,該如何調整瀏覽器大小?指令碼瀏覽器
- python 如何執行子層 py 指令碼Python指令碼
- PHP 避免同時執行一個指令碼PHP指令碼
- 怎樣在JavaScript中建立一個worker執行緒?JavaScript執行緒
- CMD 執行大檔案SQL指令碼SQL指令碼
- 使用 Terminator 在一個視窗中執行多個終端
- 為什麼建議一個容器中只執行一個程式
- shell 命令在終端可以執行成功,為什麼放在 groovy 指令碼中不執行?指令碼
- shell指令碼命令 執行python檔案&python命令列執行python程式碼指令碼Python命令列
- 如何在Windows上使用Git建立一個可執行指令碼?WindowsGit指令碼
- 我的前端元件—-多個按鈕快速點選只執行最後一次。前端元件
- 定時器setInterval,只執行一次/第一次延遲執行定時器
- pytest 框架多個 test.py 檔案怎麼控制其執行順序,除了預設的檔名 ascii 碼順序執行還有什麼外掛或者方法可以控制其執行順序麼框架ASCII
- 只在工作日執行的指令碼指令碼
- 一個“指令碼執行夯死”問題的分析指令碼
- 一個java檔案被執行的歷程Java
- 將Python指令碼打包成可執行檔案Python指令碼
- 檔案格式引起的指令碼執行錯誤指令碼
- 怎樣在windows上定時執行python指令碼WindowsPython指令碼
- 寫一個Python指令碼刪除一個.py檔案的所有註釋Python指令碼
- 請問下大家,selenium+testng+java,執行用例的時候,怎麼樣才能只開啟一次瀏覽器就能執行所有用例Java瀏覽器
- 使用此開源視窗環境一次執行多個控制檯
- drools執行String規則或執行某個規則檔案
- Laravel 中執行 Python 指令碼LaravelPython指令碼
- 執行python指令碼後臺執行Python指令碼
- 一個 java 檔案的執行過程詳解Java
- Linux中執行多個MySQL例項LinuxMySql
- 如何讓shell指令碼變成可執行檔案指令碼
- 一個工程的多個模組中的一個模組打包成jar在轉為.exe可執行檔案JAR
- 執行py檔案 File "<stdin>", line 1 SyntaxError: invalid syntaxError
- 多執行緒下載檔案執行緒
- 執行shell指令碼指令碼
- Nexus.js介紹:一個多執行緒的JavaScript執行庫JS執行緒JavaScript