Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions src/org/labkey/test/pages/assay/AssayImportPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import java.io.File;

import static org.labkey.test.util.EscapeUtil.getTableViewFormFieldName;

public class AssayImportPage extends LabKeyPage<AssayImportPage.Elements>
{
public AssayImportPage(WebDriver driver)
Expand All @@ -38,28 +40,28 @@ public AssayImportPage(WebDriver driver)

public AssayImportPage setNamedInputText(String name, String text)
{
WebElement input = Locator.input(name).findElement(getDriver());
WebElement input = Locator.input(getTableViewFormFieldName(name)).findElement(getDriver());
new Input(input, getDriver()).set(text);
return this;
}

public AssayImportPage selectNamedFieldOption(String name, String text)
{
WebElement input = Locator.xpath("//select[@name='" + name +"']").findElement(getDriver());
WebElement input = Locator.tagWithName("select", getTableViewFormFieldName(name)).findElement(getDriver());
new OptionSelect(input).set(text);
return this;
}

public AssayImportPage setNamedTextAreaValue(String name, String text)
{
WebElement input = Locator.textarea(name).findElement(getDriver());
WebElement input = Locator.textarea(getTableViewFormFieldName(name)).findElement(getDriver());
setFormElement(input, text);
return this;
}

public AssayImportPage setFileField(String name, File file)
{
setFormElement(Locator.input(name), file);
setFormElement(Locator.input(getTableViewFormFieldName(name)), file);
return this;
}

Expand Down Expand Up @@ -93,6 +95,15 @@ public AssayImportPage selectUploadFileRadioButton()
return this;
}

public @Nullable String getFieldValue(String fieldName)
{
var input = Locator.input(getTableViewFormFieldName(fieldName));
if (isElementPresent(input))
return getFormElement(input);

return null;
}

/**
* Retrieves the file name for a field if it has been previously uploaded. In this case the server
* will display a file name with an icon and a "[remove]" link. If a value has not been previously uploaded,
Expand All @@ -112,11 +123,17 @@ public AssayImportPage selectUploadFileRadioButton()
return StringUtils.trimToNull(text.replace("[remove]", ""));
}

var fileInput = Locator.input(fieldName);
if (isElementPresent(fileInput))
return getFormElement(fileInput);
return getFieldValue(fieldName);
}

return null;
public AssayImportPage removeFileValue(String fieldName)
{
var removeFileLink = Locator.tagWithClass("div", "lk-remove-file")
.withAttribute("data-fieldname", fieldName)
.child(Locator.tagWithText("a", "remove"));

removeFileLink.findElement(getDriver()).click();
return this;
}

/* button actions */
Expand Down
1 change: 0 additions & 1 deletion src/org/labkey/test/tests/AttachmentFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ private void verifyUnavailableFile()
clickAndWait(Locator.tagWithText("a", "S1"));
clickAndWait(Locator.tagWithClass("a", "labkey-text-link").withText("edit"));
waitForElement(Locator.tagContainingText("div", "jpg_sample.jpg (unavailable)"));
assertElementNotPresent(Locator.tagWithAttributeContaining("img", "src", "/_icons/image.png"));
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions src/org/labkey/test/util/EscapeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ public static String getFormFieldName(String columnName)
return getFormFieldName(columnName, FORM_FIELD_PREFIX);
}

public static String getTableViewFormFieldName(String columnName)
{
return getFormFieldName(columnName, null);
}

/**
* Escapes special characters in a column name to be used as a form field name.
* See associated {@link org.labkey.api.query.QueryUpdateForm#getFormFieldName}
Expand Down