File Operation
File Operation cung cấp các thao tác để upload và download file thông qua trình duyệt web.
Upload File
Upload file vào input element
Upload file vào input element có type="file" trên trang web.
Tham số:
Debug Port: Port kết nối trình duyệt (bắt buộc)
Tab Index: Index của tab cần thao tác (0-based, bắt buộc)
Selector: CSS selector của input file (bắt buộc)
File Path: Đường dẫn đến file cần upload (bắt buộc)
Timeout: Thời gian chờ tối đa (milliseconds, bắt buộc)
Delay After Upload: Thời gian chờ sau khi upload (milliseconds, mặc định: 5000)
Is Send Trigger Event: Gửi sự kiện trigger (input, change, blur) (mặc định: true)
Ví dụ:
{
"resource": "fileOperation",
"operation": "uploadFile",
"debugPort": 9222,
"tabIndex": 0,
"selector": "input[type='file']",
"filePath": "C:/documents/document.pdf",
"timeout": 30000,
"delayAfterUpload": 5000,
"isTriggerEvent": true
}
💡 Lưu ý:
- File phải tồn tại trên máy tính
- Input element phải có type="file"
- Hỗ trợ nhiều loại file khác nhau
- Selector có thể sử dụng format đặc biệt: >CSS>, >XPATH>, >FRAME>, >SHADOW>, >AT>
Upload File Using Click
Upload file bằng cách click button
Upload file bằng cách click vào button upload và chọn file từ dialog.
Tham số:
Debug Port: Port kết nối trình duyệt (bắt buộc)
Tab Index: Index của tab cần thao tác (0-based, bắt buộc)
Selector: CSS selector của button upload (bắt buộc)
File Path: Đường dẫn đến file cần upload (bắt buộc)
Timeout: Thời gian chờ tối đa (milliseconds, bắt buộc)
Delay After Upload: Thời gian chờ sau khi upload (milliseconds, mặc định: 5000)
Ví dụ:
{
"resource": "fileOperation",
"operation": "uploadFileUsingClick",
"debugPort": 9222,
"tabIndex": 0,
"selector": "#upload-btn",
"filePath": "C:/images/photo.jpg",
"timeout": 30000,
"delayAfterUpload": 5000
}
💡 Lưu ý:
- Phù hợp với các trang có custom upload button
- File sẽ được chọn từ file dialog
- Cần đợi dialog xuất hiện trước khi chọn file
- Selector có thể sử dụng format đặc biệt: >CSS>, >XPATH>, >FRAME>, >SHADOW>, >AT>
Download File
Tải file từ URL về máy tính
Tải file từ URL cụ thể về máy tính với tên file tùy chỉnh.
Tham số:
File URL Remote: URL của file cần download (bắt buộc)
Local Output File Path: Đường dẫn lưu file trên máy tính (bắt buộc)
Ví dụ:
{
"resource": "fileOperation",
"operation": "downloadFile",
"fileUrl": "https://example.com/file.pdf",
"outputFilePath": "C:/downloads/file.pdf"
}
💡 Lưu ý:
- URL phải có protocol (http/https)
- Thư mục lưu phải tồn tại
- File sẽ được ghi đè nếu đã tồn tại
- Không cần debug port vì không cần kết nối trình duyệt
Download Canvas as Image
Tải canvas về dưới dạng file ảnh
Chụp ảnh canvas element và lưu dưới dạng file ảnh (PNG).
Tham số:
Debug Port: Port kết nối trình duyệt (bắt buộc)
Tab Index: Index của tab cần thao tác (0-based, bắt buộc)
Selector: CSS selector của canvas element (bắt buộc)
Local Output File Path: Đường dẫn lưu file ảnh (bắt buộc)
Timeout: Thời gian chờ tối đa (milliseconds, bắt buộc)
Ví dụ:
{
"resource": "fileOperation",
"operation": "downloadCanvasAsImage",
"debugPort": 9222,
"tabIndex": 0,
"selector": "#my-canvas",
"outputFilePath": "C:/images/canvas.png",
"timeout": 30000
}
💡 Lưu ý:
- Hỗ trợ định dạng PNG
- Canvas phải được render trên trang
- Chất lượng ảnh phụ thuộc vào độ phân giải canvas
- Selector có thể sử dụng format đặc biệt: >CSS>, >XPATH>, >FRAME>, >SHADOW>, >AT>