bulk
This commit is contained in:
27
main.go
27
main.go
@@ -216,14 +216,29 @@ func main() {
|
||||
// Create a client
|
||||
c := client.NewClient(*uploadFileHost, *uploadFilePort)
|
||||
|
||||
// Upload the file
|
||||
err := c.UploadFile(*uploadFileTabID, *uploadFileSelector, *uploadFilePath, *uploadFileSelectionTimeout, *uploadFileActionTimeout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
// Check if the local file exists
|
||||
if _, err := os.Stat(*uploadFilePath); os.IsNotExist(err) {
|
||||
fmt.Fprintf(os.Stderr, "Error: Local file does not exist: %s\n", *uploadFilePath)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("File uploaded successfully")
|
||||
// First, transfer the file to the daemon container
|
||||
fmt.Printf("Transferring file to daemon container: %s\n", *uploadFilePath)
|
||||
containerPath, err := c.UploadFileToContainer(*uploadFilePath, "")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error transferring file to container: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("File transferred to container: %s\n", containerPath)
|
||||
|
||||
// Then upload the file to the web form using the container path
|
||||
err = c.UploadFile(*uploadFileTabID, *uploadFileSelector, containerPath, *uploadFileSelectionTimeout, *uploadFileActionTimeout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error uploading file to web form: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("File uploaded to web form successfully")
|
||||
|
||||
case "submit-form":
|
||||
submitFormCmd.Parse(os.Args[2:])
|
||||
@@ -475,7 +490,7 @@ func printUsage() {
|
||||
fmt.Println(" open-tab Open a new tab and return its ID")
|
||||
fmt.Println(" load-url Load a URL in a tab")
|
||||
fmt.Println(" fill-form Fill a form field with a value")
|
||||
fmt.Println(" upload-file Upload a file to a file input")
|
||||
fmt.Println(" upload-file Transfer a file to daemon container and upload to a file input")
|
||||
fmt.Println(" submit-form Submit a form")
|
||||
fmt.Println(" get-source Get the source code of a page")
|
||||
fmt.Println(" get-element Get the HTML of an element")
|
||||
|
||||
Reference in New Issue
Block a user