A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Category_model_SelectByParentArrayId.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Category_model.php
Line: 60
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 109
Function: SelectByParentArrayId
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyhotline.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 120
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: file_get_contents(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyzalo.cache): failed to open stream: No such file or directory
Filename: drivers/Cache_file.php
Line Number: 275
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 128
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Trying to access array offset on value of type bool
Filename: drivers/Cache_file.php
Line Number: 277
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 128
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyqr_facebook_group.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 130
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeyapp_id.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 133
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeygoogle_id.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 134
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeygoogle_site_verification.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 135
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeybanner_home.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 136
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeymeta_description.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 142
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: unlink(/home/anhtest2/public_html/application/cache/Config_model_SelectByKeymeta_image.cache): No such file or directory
Filename: drivers/Cache_file.php
Line Number: 279
Backtrace:
File: /home/anhtest2/public_html/application/core/MY_Model.php
Line: 25
Function: get
File: /home/anhtest2/public_html/application/models/Config_model.php
Line: 42
Function: query_cache
File: /home/anhtest2/public_html/application/core/MY_Controller.php
Line: 144
Function: SelectByKey
File: /home/anhtest2/public_html/application/controllers/frontend/Lesson.php
Line: 9
Function: __construct
File: /home/anhtest2/public_html/index.php
Line: 315
Function: require_once
[Appium Java] Bài 3 - Cài đặt Mobile app trên Emulator và tìm package name (Native/Flutter) | Anh Tester
NỘI
DUNG BÀI HỌC
✅ Cài đặt Mobile app trên Emulator
✅ Tìm Package name và Activity của mobile app (Native/Flutter)
✅ Cài đặt Mobile app trên Emulator
1. Kéo trực tiếp file APK từ máy tính vào emulator
2. Cài app thông qua Google Play Store
🔅Kiểm tra và tạo máy ảo hỗ trợ Google Play
Mở Android Studio .
Chọn AVD Manager từ menu (trong tab Tools → Device Manager).
Nhấn Create Virtual Device .
Chọn thiết bị (ví dụ: Pixel 8 hoặc Pixel 9).
Chọn một hình ảnh hệ điều hành có nhãn Play Store .
Tạo và khởi chạy máy ảo.
🔅Đăng nhập Google Play Store
Khởi chạy máy ảo.
Mở ứng dụng Google Play Store trên emulator.
Đăng nhập bằng tài khoản Google của bạn. Nếu chưa có tài khoản Google, bạn có thể tạo mới trực tiếp.
🔅Tìm và cài đặt ứng dụng
Sau khi đăng nhập thành công, tìm kiếm ứng dụng bạn muốn cài đặt trên Google Play Store .
Nhấn Install để tải về và cài đặt ứng dụng.
🔅Sử dụng ứng dụng
Sau khi cài đặt, ứng dụng sẽ xuất hiện trong danh sách ứng dụng trên emulator.
Bạn có thể mở và kiểm tra ứng dụng.
🔅Lưu ý
Nếu máy ảo không có Google Play Store, bạn sẽ cần:
Tạo lại máy ảo hỗ trợ Google Play như hướng dẫn trên.
3. Cài file APK thông qua lệnh ADB
Kiểm tra kết nối đến các thiết bị devices thông qua ADB:
adb devices
Lưu ý: phải đảm bảo chỉ 1 thiết bị đang kết nối thì mới cài đặt file APK thông qua lệnh ADB được.
Cài đặt file APK vào device đang kết nối:
adb install đường_dẫn_đến_file_apk
Ví dụ:
adb install D:\ANHTESTER\Appium\Apps\taurus_flutter_app_android_release.apk
Trước khi cài đặt: Sau khi cài đặt: Khi có nhiều thiết bị đang kết nối thì dùng lệnh ADB install bị báo lỗi:
🔆 Một số lưu ý khi sử dụng Emulator
Cài APK trên từng emulator: Dùng lệnh sau để cài APK trên một thiết bị cụ thể:
adb -s <device_id> install <path_to_apk>
Ví dụ:
adb -s emulator-5556 install D:\ANHTESTER\Appium\Apps\taurus_flutter_app_android_release.apk
Cập nhật APK cũ trên Emulator : Sử dụng tùy chọn -r
để ghi đè bản cũ mà không xóa dữ liệu:
adb install -r đường_dẫn_đến_file_apk
Khắc phục lỗi kết nối : Nếu lệnh ADB không nhận diện emulator, thử khởi động lại server:
adb kill-server
adb start-server
Tự động kết nối với Emulator : Nếu emulator không hiển thị trong adb devices
, bạn có thể thử kết nối thủ công:
adb connect localhost:5554
Gỡ cài đặt ứng dụng trên Emulator :
adb uninstall tên_gói
Tên gói sẽ được chỉ tìm ở phần dưới. (app package, app activity)
Ví dụ:
adb uninstall com.anhtester.mobile_app.taurus
✅ Tìm Package name và Activity của mobile app (Native/Flutter)
Mục đích của việc tìm Package name và Activity là để sau này dùng code để kết nối với App Mobile thông qua Appium Java.
Khái niệm
Công dụng chính
Package name
- Định danh ứng dụng trong Desired Capabilities. - Xác định ứng dụng mục tiêu cần tự động hóa.
Activity
- Khởi động màn hình cụ thể. - Điều hướng giữa các màn hình. - Xác nhận trạng thái ứng dụng.
Cả hai đều được sử dụng song song trong Appium để thiết lập môi trường kiểm thử, khởi chạy ứng dụng, và kiểm thử các màn hình cụ thể một cách tự động.
1. Sử dụng 'mCurrentFocus' hoặc 'mFocusedApp' trong Command Prompt
Sau khi có được App Package và App Activity thì chúng ta sẽ gắn vào code Appium Java để khởi chạy mở được app đúng với màn hình cần hiển thị lên, thường là màn hình đầu tiên.Ví dụ:
UiAutomator2Options options = new UiAutomator2Options();
options.setPlatformName("Android");
options.setPlatformVersion("15");
options.setAutomationName("UiAutomator2");
options.setAppPackage("com.anhtester.mobile_app.taurus");
options.setAppActivity("com.anhtester.mobile_app.taurus.MainActivity")
2. Sử dụng Logcat trên Android Studio
Mở ứng dụng trên emulator trong Android Studio
Từ thanh menu ngang bên trên cùng chọn View > Tool Windows > Logcat
Xoá giá trị trong ô filter hiện tại và nhập giá trị "Displayed "
Logcat sẽ hiển thị logs chứa dòng app package và app activity cho màn hình hiện tại của app đang mở trên emulator.
Software Quality Engineer
Đường dẫu khó chân vẫn cần bước đi Đời dẫu khổ tâm vẫn cần nghĩ thấu
Chia sẻ khóa học lên trang
Bạn có thể đăng khóa học của chính bạn lên trang
Anh Tester để kiếm tiền