Clicks the matched element and gives the file to the input behind it. Mandatory parameter: elementId. Optional: css, gpalElements, modifiers, uploadPath for one file, and uploadPaths for several. One of css, elementId, gpalElements, or modifiers must be present. The request goes out as multipart, which is why this route is the only one that does not send its parameters as plain JSON. How the file reaches the input differs per engine and the fluent call picks the path for you, so the engine samples below are what each one does underneath rather than four ways of asking.
Attaching more than one file: build a GPALFile with a WithFileName call per file and pass the one object. Selenium sends the whole set in a single call, paths separated by newlines, but only when the input carries the multiple property, because chromedriver adds a file on every send and geckodriver throws on the second. Puppeteer sends uploadPaths instead of uploadPath once there is more than one. OttoMagic sends one file per call and keeps the files already on the input, so several calls build the set up rather than replace it.
Hardware input needs a window. The hardware path types into the dialog the browser opens, and a headless browser opens no dialog, so asking for hardware input on a headless run leaves the file unattached and the workflow carrying on as though it worked. The dialog is also named differently per browser, Open on Chrome and Edge and File Upload on Firefox, so a browser GPAL does not recognise finds no window and the upload is reported as a failure.
//This is the call to reach for. It reads the GPALFile, picks the engine path, and publishes an INFO event naming each file as it goes. A second WithFileName adds a file rather than replacing the first. Hardware input is the one path that opens the real file dialog, and it is chosen by the selector or by the browser settings rather than by this call.
GPALFile uploadFiles = GPAL
browser
//Two overloads over the same route, one taking a path and one a GPALFile, which pick WithUploadFile or WithUploadFiles for you. The element is named by its Css, which is what an OttoMagic element id is. OttoMagic cannot read your disk from the page, so the native app reads the file and sends the bytes with its name and type; the extension rebuilds it in the page, adds it to the ones already on the input, and raises change and input. A large file makes that whole journey in memory.
browser
// or hand it a GPALFile
browser
//LeftClickAndUpload takes a GPALElement, a list of them, or an element id. UploadFrom reads the GPALFile and sends uploadPath for one file or uploadPaths for more than one, which Puppeteer sets on the input over CDP without a dialog.
browser
//The file argument is typed as object and takes a single path or any list of them, and the paths are made absolute before they are sent. The modifiers argument is carried for consistency with the other click routes and is not read here.
await browser
// a list of paths attaches all of them
await browser
//WithUploadFile takes a single path and WithUploadFiles takes a GPALFile. Both force the request to POST, since the file travels in the body rather than in the parameters.
browser
// several files, from a GPALFile
browser
Showing off some plain text in these paragraphs eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo veniam mollitia excepturi animi eum illum non libero sapiente provident assumenda, delectus voluptatum nobis sed dolorem adipisci laudantium incidunt. Error, ratione?
Here you can find different accents and emphasis sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
This is a link and how it could look like bestlinkinthebeautifulworld. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Here's just some classic bold text adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam notBoldSecondbestlinkinthebeautifulworld illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at adipisicing elit libero vel voluptas? Expedita, adipisicing facere dolores voluptatem ad ab rem assumenda soluta!
Other cuple of colors in case we want to emphasize several ways adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam adipisicing elit illo nostrum corporis at voluptatem libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta! Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quod veniam, quam ad expedita laborum sed at voluptates culpa ipsam ut vel. Ullam temporibus a mollitia quod aliquam ratione exercitationem nesciunt.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, iste distinctio veritatis eligendi laboriosam illo nostrum corporis at libero vel voluptas? Expedita, facere dolores voluptatem ad ab rem assumenda soluta!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae quas consequuntur illo numquam assumenda autem exercitationem distinctio perspiciatis in natus. Eius dicta similique ipsam ipsa minima, nemo quae enim tempore.
GPAL
.CallIfNotFound(GenericCallIfNotFound)
.WithPublishToConsole();
//System.Drawing.Rectangle windowSize = new System.Drawing.Rectangle(10, 10, 1500, 1024);
// NOTE: we have to set browser = before we execute any steps
// this is due to the 'GenericCallIfNotFound' which might throw an exception, and BankScraper will not have the browser set when it calls scraper.Close()
// until the complete fluent line gets executed (meaning every step, meaning browser is not set until everything else succeeds)
browser = GPAL.Browser
.WithBrowserType(Enums.BrowserType.Chrome)
.WithProfileDataDirectory(ChromeProfileLocation)
.WithUseAutomationEngine(AutomationEngine.Selenium)
.WithWindowSize(new System.Drawing.Rectangle(0,0,1920,1080))
.ToGPALObject();