Skip to content

FileInput

Taisiia-Kozlova edited this page Nov 7, 2017 · 3 revisions

FileInput – special text-field that accepts file-paths and which is used for uploading documents.

Perhaps, it’s not widely utilized by users, but for needs of test automation, pasting a file-path is a more convenient way of uploading documents, than having to deal with system’s dialogue windows.

Example:

FileInput

JDI enables simple ways of interaction with text-fields, such as text input, text removal and cursor focus on chosen field.

Here is the list of available methods.

Method Description Return Type
input(String) Input text in textfield void
newInput(String) Clear and input text in textfield void
clear() Clear textfield void
focus() Focus (click) on textfield void

FileInput Initialization:

@FindBy(xpath = "//file-input xpath")
public FileInput fileInput;

Action > Examples:

@Test
public void newInputExample() {
    Assert.assertTrue(!fileInput.getText().equals("")
    String path = "some path";
    fileInput.newInput(path);
    Assert.assertEquals(fileInput.getText(), path);
}

See more examples on GitHub

Clone this wiki locally