Interface FormData
-
public interface FormDataTheFormDatais used create form data that is sent viaAPIRequestContext.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));
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description FormDataappend(String name, boolean value)Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.FormDataappend(String name, int value)Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.FormDataappend(String name, FilePayload value)Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.FormDataappend(String name, String value)Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.FormDataappend(String name, Path value)Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.static FormDatacreate()Creates new instance ofFormData.FormDataset(String name, boolean value)Sets a field on the form.FormDataset(String name, int value)Sets a field on the form.FormDataset(String name, FilePayload value)Sets a field on the form.FormDataset(String name, String value)Sets a field on the form.FormDataset(String name, Path value)Sets a field on the form.
-
-
-
Method Detail
-
append
FormData append(String name, String value)
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 asPathor asFilePayload. Multiple fields with the same name can be added.The difference between
FormData.set()andFormData.append()is that if the specified key already exists,FormData.set()will overwrite all existing values with the new one, whereasFormData.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() // Only name and value are set. .append("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .append("attachment", Paths.get("pic.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.44
-
append
FormData append(String name, boolean value)
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 asPathor asFilePayload. Multiple fields with the same name can be added.The difference between
FormData.set()andFormData.append()is that if the specified key already exists,FormData.set()will overwrite all existing values with the new one, whereasFormData.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() // Only name and value are set. .append("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .append("attachment", Paths.get("pic.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.44
-
append
FormData append(String name, int value)
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 asPathor asFilePayload. Multiple fields with the same name can be added.The difference between
FormData.set()andFormData.append()is that if the specified key already exists,FormData.set()will overwrite all existing values with the new one, whereasFormData.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() // Only name and value are set. .append("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .append("attachment", Paths.get("pic.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.44
-
append
FormData append(String name, Path value)
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 asPathor asFilePayload. Multiple fields with the same name can be added.The difference between
FormData.set()andFormData.append()is that if the specified key already exists,FormData.set()will overwrite all existing values with the new one, whereasFormData.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() // Only name and value are set. .append("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .append("attachment", Paths.get("pic.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.44
-
append
FormData append(String name, FilePayload value)
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 asPathor asFilePayload. Multiple fields with the same name can be added.The difference between
FormData.set()andFormData.append()is that if the specified key already exists,FormData.set()will overwrite all existing values with the new one, whereasFormData.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() // Only name and value are set. .append("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .append("attachment", Paths.get("pic.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.44
-
create
static FormData create()
Creates new instance ofFormData.- Since:
- v1.18
-
set
FormData set(String name, String value)
Sets a field on the form. File values can be passed either asPathor asFilePayload.import com.microsoft.playwright.options.FormData; ... FormData form = FormData.create() // Only name and value are set. .set("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .set("profilePicture1", Paths.get("john.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.18
-
set
FormData set(String name, boolean value)
Sets a field on the form. File values can be passed either asPathor asFilePayload.import com.microsoft.playwright.options.FormData; ... FormData form = FormData.create() // Only name and value are set. .set("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .set("profilePicture1", Paths.get("john.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.18
-
set
FormData set(String name, int value)
Sets a field on the form. File values can be passed either asPathor asFilePayload.import com.microsoft.playwright.options.FormData; ... FormData form = FormData.create() // Only name and value are set. .set("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .set("profilePicture1", Paths.get("john.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.18
-
set
FormData set(String name, Path value)
Sets a field on the form. File values can be passed either asPathor asFilePayload.import com.microsoft.playwright.options.FormData; ... FormData form = FormData.create() // Only name and value are set. .set("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .set("profilePicture1", Paths.get("john.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.18
-
set
FormData set(String name, FilePayload value)
Sets a field on the form. File values can be passed either asPathor asFilePayload.import com.microsoft.playwright.options.FormData; ... FormData form = FormData.create() // Only name and value are set. .set("firstName", "John") // Name and value are set, filename and Content-Type are inferred from the file path. .set("profilePicture1", Paths.get("john.jpg")) // Name, value, filename and Content-Type are set. .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));- Parameters:
name- Field name.value- Field value.- Since:
- v1.18
-
-