The FormData is used create form data that is sent via APIRequestContext.
import com.microsoft.playwright.options.FormData;
FormData form = FormData.create()
.set("firstName", "John")
.set("lastName", "Doe")
.set("age", 30);
page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
Methods appendAdded in: v1.44 formData.append
Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File values can be passed either as Path
or as FilePayload
. Multiple fields with the same name can be added.
The difference between FormData.set() and FormData.append() is that if the specified key already exists, FormData.set() will overwrite all existing values with the new one, whereas FormData.append() will append the new value onto the end of the existing set of values.
import com.microsoft.playwright.options.FormData;
FormData form = FormData.create()
.append("firstName", "John")
.append("attachment", Paths.get("pic.jpg"))
.append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
Usage
FormData.append(name, value);
Arguments
Returns
createAdded in: v1.18 formData.createCreates new instance of FormData.
Usage
Returns
setAdded in: v1.18 formData.setSets a field on the form. File values can be passed either as Path
or as FilePayload
.
import com.microsoft.playwright.options.FormData;
FormData form = FormData.create()
.set("firstName", "John")
.set("profilePicture1", Paths.get("john.jpg"))
.set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
.set("age", 30);
page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
Usage
FormData.set(name, value);
Arguments
Returns
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4