diff --git a/src/org/labkey/test/pages/DatasetInsertPage.java b/src/org/labkey/test/pages/DatasetInsertPage.java
index 3d014dc623..4651210bdf 100644
--- a/src/org/labkey/test/pages/DatasetInsertPage.java
+++ b/src/org/labkey/test/pages/DatasetInsertPage.java
@@ -18,11 +18,14 @@
import org.apache.tika.utils.StringUtils;
import org.labkey.test.Locator;
import org.labkey.test.Locators;
+import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.Map;
+import static org.labkey.test.util.EscapeUtil.FORM_FIELD_PREFIX;
+
public class DatasetInsertPage extends InsertPage
{
public DatasetInsertPage(WebDriver driver, String datasetName)
@@ -39,7 +42,7 @@ public DatasetInsertPage(WebDriver driver)
protected void waitForReady()
{
super.waitForReady();
- waitForElement(Locator.tag("*").attributeStartsWith("name", "quf_"));
+ waitForElement(Locator.tag("*").attributeStartsWith("name", FORM_FIELD_PREFIX));
}
public void insert(Map values)
@@ -79,7 +82,7 @@ private void tryInsert(Map values)
{
for (Map.Entry entry : values.entrySet())
{
- WebElement fieldInput = Locator.name("quf_" + entry.getKey()).findElement(getDriver());
+ WebElement fieldInput = Locator.name(EscapeUtil.getFormFieldName(entry.getKey())).findElement(getDriver());
String type = fieldInput.getAttribute("type");
switch (type)
{
diff --git a/src/org/labkey/test/pages/query/UpdateQueryRowPage.java b/src/org/labkey/test/pages/query/UpdateQueryRowPage.java
index d4795e5808..dcb2efa47e 100644
--- a/src/org/labkey/test/pages/query/UpdateQueryRowPage.java
+++ b/src/org/labkey/test/pages/query/UpdateQueryRowPage.java
@@ -12,6 +12,7 @@
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.OptionSelect;
import org.labkey.test.pages.LabKeyPage;
+import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@@ -185,7 +186,7 @@ WebElement findField(String name)
{
if (!fieldMap.containsKey(name))
{
- fieldMap.put(name, Locator.name("quf_" + name).findElement(this));
+ fieldMap.put(name, Locator.name(EscapeUtil.getFormFieldName(name)).findElement(this));
}
return fieldMap.get(name);
}
diff --git a/src/org/labkey/test/pages/user/UpdateUserDetailsPage.java b/src/org/labkey/test/pages/user/UpdateUserDetailsPage.java
index 4f8150f4b2..9b0f0b25b5 100644
--- a/src/org/labkey/test/pages/user/UpdateUserDetailsPage.java
+++ b/src/org/labkey/test/pages/user/UpdateUserDetailsPage.java
@@ -5,6 +5,7 @@
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.html.Input;
import org.labkey.test.pages.LabKeyPage;
+import org.labkey.test.util.EscapeUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
@@ -109,7 +110,7 @@ protected Input findInput(String fieldName)
{
if (!formElements.containsKey(fieldName))
{
- Input input = Input.Input(Locator.name("quf_" + fieldName), getDriver()).find();
+ Input input = Input.Input(Locator.name(EscapeUtil.getFormFieldName(fieldName)), getDriver()).find();
formElements.put(fieldName, input);
}
return formElements.get(fieldName);
diff --git a/src/org/labkey/test/tests/AliquotTest.java b/src/org/labkey/test/tests/AliquotTest.java
index 0028f4169c..3a95f168fe 100644
--- a/src/org/labkey/test/tests/AliquotTest.java
+++ b/src/org/labkey/test/tests/AliquotTest.java
@@ -24,6 +24,7 @@
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Specimen;
import org.labkey.test.components.html.BootstrapMenu;
+import org.labkey.test.components.html.OptionSelect;
import org.labkey.test.pages.ImportDataPage;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.LogMethod;
@@ -274,12 +275,12 @@ private void verifyInsertingSpecimens()
// verify insert new here
DataRegionTable detail = new DataRegionTable("SpecimenDetail", this);
- detail.clickInsertNewRow();
- setFormElement(Locator.xpath("//input[@name='quf_GlobalUniqueId']"), "Global");
- setFormElement(Locator.xpath("//input[@name='quf_VisitDescription']"), "NewVisit");
- setFormElement(Locator.xpath("//input[@name='quf_SequenceNum']"), "001");
- selectOptionByText(Locator.name("quf_ParticipantId"), "618005775");
- clickButton("Submit");
+ detail.clickInsertNewRow()
+ .setField("GlobalUniqueId", "Global")
+ .setField("VisitDescription", "NewVisit")
+ .setField("SequenceNum", "001")
+ .setField("ParticipantId", OptionSelect.SelectOption.textOption("618005775"))
+ .submit();
assertElementNotPresent(Locator.tagWithClass("*", "labkey-error").withText());
detail.setFilter("VisitDescription", "Equals", "NewVisit");
assertTextPresent("NewVisit");
diff --git a/src/org/labkey/test/tests/AttachmentFieldTest.java b/src/org/labkey/test/tests/AttachmentFieldTest.java
index 673002985b..6ccf85af4b 100644
--- a/src/org/labkey/test/tests/AttachmentFieldTest.java
+++ b/src/org/labkey/test/tests/AttachmentFieldTest.java
@@ -3,6 +3,7 @@
import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -10,11 +11,9 @@
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.categories.Daily;
-import org.labkey.test.components.DomainDesignerPage;
-import org.labkey.test.components.domain.DomainFieldRow;
-import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.admin.FileRootsManagementPage;
import org.labkey.test.pages.experiment.UpdateSampleTypePage;
+import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.DataRegionTable;
@@ -58,14 +57,18 @@ private void doSetup()
portalHelper.addBodyWebPart("Lists");
}
+ @Before
+ public void preTest()
+ {
+ goToProjectHome();
+ }
+
@Test
public void testFileFieldInSampleType()
{
- goToProjectHome();
String sampleTypeName = "Sample type with attachment";
String fieldName = "testFile";
SampleTypeHelper sampleTypeHelper = new SampleTypeHelper(this);
- goToProjectHome();
log("Create a sample type with attachment field");
sampleTypeHelper.createSampleType(new SampleTypeDefinition(sampleTypeName)
@@ -76,11 +79,13 @@ public void testFileFieldInSampleType()
log("Inserting samples in sample Type");
goToProjectHome();
clickAndWait(Locator.linkWithText(sampleTypeName));
- DataRegionTable samplesTable = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor();
- samplesTable.clickInsertNewRow();
- setFormElement(Locator.name("quf_Name"), "S1");
- setFormElement(Locator.name("quf_" + fieldName), SAMPLE_FILE);
- clickButton("Submit");
+
+ DataRegionTable.DataRegion(getDriver()).withName("Material")
+ .waitFor()
+ .clickInsertNewRow()
+ .setField("Name", "S1")
+ .setField(fieldName, SAMPLE_FILE)
+ .submit();
assertElementPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));
@@ -113,7 +118,7 @@ public void testFileFieldInSampleType()
fileRootsManagementPage = goToFolderManagement().goToFilesTab();
fileRootsManagementPage.useCustomFileRoot(childFileRoot).clickSave();
- // verify file path display for files that's present but outside of current file root
+ // verify file path display for files that are present but outside the current file root
verifyUnavailableFile();
// reset file root to default
@@ -125,7 +130,7 @@ public void testFileFieldInSampleType()
clickAndWait(Locator.linkWithText(sampleTypeName));
assertElementPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));
- // delete the file and verify file path that doesn't exist
+ // delete the file and verify the file path that doesn't exist
goToModule("FileContent");
_fileBrowserHelper.deleteFile("sampletype");
verifyUnavailableFile();
@@ -139,12 +144,11 @@ private void verifyUnavailableFile()
waitForElement(Locator.tagContainingText("td", "jpg_sample.jpg (unavailable)"));
assertElementNotPresent(Locator.tagWithAttribute("a", "title", "Download attached file"));
- // "(unavailable)" suffix is present in update view
+ // "(unavailable)" suffix is present in the update view
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
@@ -152,26 +156,23 @@ public void testAttachmentFieldInLists()
{
String listName = TestDataGenerator.randomDomainName("List with attachment field");
String fieldName = TestDataGenerator.randomFieldName("Test File");
- goToProjectHome();
log("Creating the list");
_listHelper.createList(getProjectName(), listName, "id");
log("Adding a attachment field with Show attachment in Browser");
- DomainDesignerPage domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "lists", listName);
- DomainFormPanel panel = domainDesignerPage.fieldsPanel();
- DomainFieldRow stringRow = panel
- .addField(fieldName)
- .setType(FieldDefinition.ColumnType.Attachment);
- stringRow.setAttachmentBehavior("Show Attachment in Browser");
- domainDesignerPage.clickFinish();
+ EditListDefinitionPage editPage = _listHelper.goToEditDesign(listName)
+ .addField(new FieldDefinition(fieldName, FieldDefinition.ColumnType.Attachment));
+ editPage.getFieldsPanel()
+ .getField(fieldName)
+ .setAttachmentBehavior("Show Attachment in Browser");
+ editPage.clickSave();
log("Insert row in list");
- goToProjectHome();
- clickAndWait(Locator.linkWithText(listName));
- DataRegionTable listTable = new DataRegionTable("query", getDriver());
- listTable.clickInsertNewRow();
- setFormElement(Locator.name("quf_" + fieldName), SAMPLE_FILE);
- clickButton("Submit");
+ _listHelper.beginAtList(getProjectName(), listName);
+ new DataRegionTable("query", getDriver())
+ .clickInsertNewRow()
+ .setField(fieldName, SAMPLE_FILE)
+ .submit();
log("Verify file opened in browser");
Locator.tagWithAttributeContaining("img", "title", SAMPLE_FILE.getName()).findElement(getDriver()).click();
@@ -181,13 +182,12 @@ public void testAttachmentFieldInLists()
switchToMainWindow();
log("Verify file is downloaded");
- domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "lists", listName);
- panel = domainDesignerPage.fieldsPanel();
- panel.getField(fieldName).setAttachmentBehavior("Download Attachment");
- domainDesignerPage.clickFinish();
+ editPage = _listHelper.goToEditDesign(listName);
+ editPage.getFieldsPanel()
+ .getField(fieldName)
+ .setAttachmentBehavior("Download Attachment");
+ editPage.clickSave();
- goToProjectHome();
- clickAndWait(Locator.linkWithText(listName));
File downloadedFile = doAndWaitForDownload(() -> Locator.tagWithAttributeContaining("img", "title", SAMPLE_FILE.getName()).findElement(getDriver()).click());
Assert.assertTrue("Downloaded file is empty", downloadedFile.length() > 0);
}
diff --git a/src/org/labkey/test/tests/DataClassFolderExportImportTest.java b/src/org/labkey/test/tests/DataClassFolderExportImportTest.java
index da3cb09146..b112ddaf14 100644
--- a/src/org/labkey/test/tests/DataClassFolderExportImportTest.java
+++ b/src/org/labkey/test/tests/DataClassFolderExportImportTest.java
@@ -124,13 +124,13 @@ public void testExportImportSimpleDataClass() throws Exception
clickAndWait(Locator.linkWithText(testDataClass));
DataRegionTable sourceTable = DataRegionTable.DataRegion(getDriver()).withName("query").waitFor();
- for (int i=0; i<_attachments.size(); i++)
- { // for the nonce, we cannot add file attachments to an attachment column via remoteAPI
- // issue https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=42191 tracks this
- // until it is fixed we will have to add attachments via the UI, like this
- sourceTable.clickEditRow(i);
- setFormElement(Locator.input("quf_" + attachmentColumnName), _attachments.get(i));
- clickButton("Submit");
+ for (int i = 0; i < _attachments.size(); i++)
+ {
+ // For the nonce, we cannot add file attachments to an attachment column via remoteAPI
+ // Issue 42191 tracks this until it is fixed we will have to add attachments via the UI
+ sourceTable.clickEditRow(i)
+ .setField(attachmentColumnName, _attachments.get(i))
+ .submit();
}
List
- * @throws IOException Can be thrown by helper that checks if the list already exists.
- * @throws CommandException Can be thrown by helper that checks if the list already exists.
*/
@Test
- public void testDateAndTimeColumnFiltering() throws IOException, CommandException
+ public void testDateAndTimeColumnFiltering()
{
-
String listName = "Date and Time Filter List";
String dateCol = "Date";
String timeCol = "Time";
@@ -802,15 +795,15 @@ public void testDateAndTimeColumnFiltering() throws IOException, CommandExceptio
StringBuilder bulkInsertText = new StringBuilder();
bulkInsertText.append(String.format("%s\t%s\n", dateCol, timeCol));
- for(Date date : dates)
+ for (Date date : dates)
{
- if(date.equals(dateUseDateOnlyKey10))
+ if (date.equals(dateUseDateOnlyKey10))
{
// Add a line with only a date.
bulkInsertText.append(String.format("%s\t\n", _defaultDateFormat.format(date)));
}
- else if(date.equals(dateUseTimeOnlyKey11))
+ else if (date.equals(dateUseTimeOnlyKey11))
{
// Add a line with only a time.
bulkInsertText.append(String.format("\t%s\n", _defaultTimeFormat.format(date)));
@@ -820,7 +813,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
bulkInsertText.append(String.format("%s\t%s\n",
_defaultDateFormat.format(date), _defaultTimeFormat.format(date)));
}
-
}
log("Use bulk insert to populate the list.");
@@ -861,7 +853,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering date-only column to equal '%s' (duplicate values) not as expected.", filterValue01),
"Error_Date_Filter_Equals_Duplicates");
-
Date filterDate01 = new Calendar.Builder()
.setDate(2010, 1, 1)
.build().getTime();
@@ -878,7 +869,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering date-only column greater than or equal to '%s' not as expected.", filterValue01),
"Error_Date_Filter_Greater");
-
// Filter between two dates.
filterDate01 = new Calendar.Builder()
.setDate(2001, 1, 1)
@@ -903,7 +893,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering date-only column between '%s' and '%s' not as expected.", filterValue01, filterValue02),
"Error_Date_Filter_Between");
-
log("Filter the date-only is blank.");
expectedKeyCol = new ArrayList<>();
@@ -915,7 +904,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
"Filtering date-only to 'Is Blank' not as expected.",
"Error_Date_Filter_Blank");
-
log("Now filter the time-only field.");
filterValue01 = _defaultTimeFormat.format(dateKey07);
@@ -942,7 +930,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering time-only column to equal '%s' (no seconds) not as expected.", filterValue01),
"Error_Time_Filter_No_Seconds");
-
filterValue01 = _defaultTimeFormat.format(dateDuplicate);
log(String.format("Filter the time-only field equals '%s' which has duplicates.", filterValue01));
expectedKeyCol = new ArrayList<>();
@@ -955,7 +942,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering time-only column to equal '%s' (duplicate values) not as expected.", filterValue01),
"Error_Time_Filter_Equals_Duplicates");
-
filterDate01 = new Calendar.Builder()
.setTimeOfDay(14, 0, 0)
.build().getTime();
@@ -974,7 +960,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering time-only column greater than or equal to '%s' not as expected.", filterValue01),
"Error_Time_Filter_Greater");
-
filterDate01 = new Calendar.Builder()
.setTimeOfDay(9, 0, 0)
.build().getTime();
@@ -1002,7 +987,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
String.format("Filtering time-only column between '%s' and '%s' not as expected.", filterValue01, filterValue02),
"Error_Time_Filter_Between");
-
log("Filter the time-only is blank.");
expectedKeyCol = new ArrayList<>();
expectedKeyCol.add("10"); // 1989-08-12 (empty)
@@ -1012,7 +996,6 @@ else if(date.equals(dateUseTimeOnlyKey11))
null, null,
"Filtering time-only to 'Is Blank' not as expected.",
"Error_Time_Filter_Blank");
-
}
/**
@@ -1020,13 +1003,10 @@ else if(date.equals(dateUseTimeOnlyKey11))
* Validate error messages are expected for invalid values in date-only, time-only and DateTime fields.
* Validates bulk import, file (xlsx) and UI.
*
- * @throws IOException Can be thrown by helper that checks if the list already exists.
- * @throws CommandException Can be thrown by helper that checks if the list already exists.
*/
@Test
- public void testInvalidDateAndTimeInsert() throws IOException, CommandException
+ public void testInvalidDateAndTimeInsert()
{
-
String listName = "Date and Time Invalid Insert List";
String dateCol = "Date";
String timeCol = "Time";
@@ -1051,7 +1031,6 @@ public void testInvalidDateAndTimeInsert() throws IOException, CommandException
ImportDataPage importPage = _listHelper.clickImportData();
-
String bulkImportText = String.format("%s\t\n%s", dateCol, badDate);
importPage.setText(bulkImportText);
String actualErrorMsg = importPage.submitExpectingError();
@@ -1099,18 +1078,17 @@ public void testInvalidDateAndTimeInsert() throws IOException, CommandException
_listHelper.beginAtList(getProjectName(), listName);
- DataRegionTable regionTable = new DataRegionTable("query", getDriver());
- regionTable.clickInsertNewRow();
- setFormElement(Locator.name("quf_" + timeCol), badTime);
- setFormElement(Locator.name("quf_" + dateCol), badDate);
- setFormElement(Locator.name("quf_" + dateTimeCol), badDateTime);
- clickButton("Submit");
+ new DataRegionTable("query", getDriver())
+ .clickInsertNewRow()
+ .setField(timeCol, badTime)
+ .setField(dateCol, badDate)
+ .setField(dateTimeCol, badDateTime)
+ .submit();
checker().verifyTrue("Bad value error message in UI not as expected.",
isTextPresent(String.format("Could not convert value: %s", badTime),
String.format("Could not convert value: %s", badDate),
String.format("Could not convert value: %s", badDateTime)));
-
}
/**
@@ -1180,7 +1158,7 @@ public void testDateAndTimeFormat()
SimpleDateFormat inputTimeFormatter = new SimpleDateFormat("hh:mm:ss aa");
SimpleDateFormat inputDateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- for(Date date : dates)
+ for (Date date : dates)
{
bulkImportText.append(String.format("%s\t%s\t%s\n",
inputDateFormatter.format(date), inputTimeFormatter.format(date), inputDateTimeFormatter.format(date)
@@ -1193,7 +1171,7 @@ public void testDateAndTimeFormat()
List> expectedData = new ArrayList<>();
- for(Date date : dates)
+ for (Date date : dates)
{
expectedData.add(
Map.of(
@@ -1237,7 +1215,7 @@ public void testDateAndTimeFormat()
expectedData = new ArrayList<>();
- for(Date date : dates)
+ for (Date date : dates)
{
expectedData.add(
Map.of(
@@ -1256,13 +1234,10 @@ public void testDateAndTimeFormat()
* Test converting a DateTime filed to a date-only and time-only field. Test also validates that a date-only
* field can be converted to a DateTime field, but a time-only field can not.
*
- * @throws IOException Can be thrown by helper that checks if the list already exists.
- * @throws CommandException Can be thrown by helper that checks if the list already exists.
*/
@Test
- public void testConvertDateTimeField() throws IOException, CommandException
+ public void testConvertDateTimeField()
{
-
String listName = "Convert DateTime Field List";
String dateTimeToTimeCol = "DT_To_Time";
String dateTimeToDateCol = "DT_To_Date";
@@ -1321,7 +1296,7 @@ public void testConvertDateTimeField() throws IOException, CommandException
bulkImportText.append(String.format("%s\t%s\n", dateTimeToDateCol, dateTimeToTimeCol));
- for(Date date : dates)
+ for (Date date : dates)
{
bulkImportText.append(String.format("%s\t%s\n",
_defaultDateTimeFormat.format(date), formatterFormatTime.format(date)
@@ -1381,7 +1356,7 @@ public void testConvertDateTimeField() throws IOException, CommandException
List> expectedData = new ArrayList<>();
- for(Date date : dates)
+ for (Date date : dates)
{
expectedData.add(
Map.of(
@@ -1429,7 +1404,7 @@ public void testConvertDateTimeField() throws IOException, CommandException
expectedData = new ArrayList<>();
- for(Date date : dates)
+ for (Date date : dates)
{
expectedData.add(
Map.of(
@@ -1442,7 +1417,5 @@ public void testConvertDateTimeField() throws IOException, CommandException
validateListDataInUI(table, expectedData);
checker().screenShotIfNewError("Convert_To_DateTime_Error");
-
}
-
}
diff --git a/src/org/labkey/test/tests/list/ListTest.java b/src/org/labkey/test/tests/list/ListTest.java
index 73862cf52a..0d8c94b83e 100644
--- a/src/org/labkey/test/tests/list/ListTest.java
+++ b/src/org/labkey/test/tests/list/ListTest.java
@@ -329,14 +329,14 @@ protected void setUpList()
// Second row (Green)
assertEquals(1, table.getRowIndex(TEST_DATA[TD_COLOR][1]));
table.clickEditRow(1);
- setFormElement(Locator.name("quf_" + _listColMonth.getName()), VALID_MONTHS[1]); // Has a funny format -- need to post converted date
- checkCheckbox(Locator.checkboxByName("quf_JewelTone"));
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColMonth.getName())), VALID_MONTHS[1]); // Has a funny format -- need to post converted date
+ checkCheckbox(Locator.checkboxByName(EscapeUtil.getFormFieldName("JewelTone")));
clickButton("Submit");
// Third row (Red)
assertEquals(2, table.getRowIndex(TEST_DATA[TD_COLOR][2]));
table.clickEditRow(2);
- setFormElement(Locator.name("quf_" + _listColMonth.getName()), VALID_MONTHS[2]); // Has a funny format -- need to post converted date
- uncheckCheckbox(Locator.checkboxByName("quf_JewelTone"));
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColMonth.getName())), VALID_MONTHS[2]); // Has a funny format -- need to post converted date
+ uncheckCheckbox(Locator.checkboxByName(EscapeUtil.getFormFieldName("JewelTone")));
clickButton("Submit");
table = new DataRegionTable("query", getDriver());
@@ -413,12 +413,12 @@ protected void setUpList()
String html = getHtmlSource();
assertTrue("Description \"" + _listColDesc.getDescription() + "\" not present.", html.contains(_listColDesc.getDescription()));
assertTrue("Description \"" + _listColTone.getDescription() + "\" not present.", html.contains(_listColTone.getDescription()));
- setFormElement(Locator.name("quf_" + _listColDesc.getName()), TEST_DATA[TD_DESC][3]);
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColDesc.getName())), TEST_DATA[TD_DESC][3]);
// Jewel Tone checkbox is left blank -- we'll make sure it's posted as false below
- setFormElement(Locator.name("quf_" + _listColGood.getName()), TEST_DATA[TD_GOOD][3]);
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(_listColGood.getName())), TEST_DATA[TD_GOOD][3]);
clickButton("Submit");
assertTextPresent("This field is required");
- setFormElement(Locator.name("quf_" + LIST_KEY_NAME2), TEST_DATA[TD_COLOR][3]);
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(LIST_KEY_NAME2)), TEST_DATA[TD_COLOR][3]);
clickButton("Submit");
log("Check new row was added");
@@ -1649,9 +1649,9 @@ public void testAutoIncrementKeyEncoded()
// insert a new row and verify the key is encoded in the form input
table.clickInsertNewRow();
String html = getHtmlSource();
- checker().verifyFalse("List key hidden input not present.", html.contains("quf_" + encodedKeyName));
+ checker().verifyFalse("List key hidden input not present.", html.contains(EscapeUtil.getFormFieldName(encodedKeyName)));
String nameValue = "test";
- setFormElement(Locator.name("quf_Name"), nameValue);
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName("Name")), nameValue);
clickButton("Submit");
// verify the name value is persisted
@@ -1662,9 +1662,9 @@ public void testAutoIncrementKeyEncoded()
// verify name value can be updated
table.clickEditRow(0);
html = getHtmlSource();
- checker().verifyTrue("List key hidden input not present.", html.contains("quf_" + encodedKeyName));
+ checker().verifyTrue("List key hidden input not present.", html.contains(EscapeUtil.getFormFieldName(encodedKeyName)));
nameValue = "test updated";
- setFormElement(Locator.name("quf_Name"), nameValue);
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName("Name")), nameValue);
clickButton("Submit");
// verify the name value is persisted
diff --git a/src/org/labkey/test/util/DataClassHelper.java b/src/org/labkey/test/util/DataClassHelper.java
index 67dd56f9b4..527a3f17e6 100644
--- a/src/org/labkey/test/util/DataClassHelper.java
+++ b/src/org/labkey/test/util/DataClassHelper.java
@@ -143,7 +143,7 @@ public void insertRow(Map fieldValues)
.clickInsertNewRow();
for (Map.Entry fieldValue : fieldValues.entrySet())
{
- setFormElement(Locator.name("quf_" + fieldValue.getKey()), fieldValue.getValue());
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(fieldValue.getKey())), fieldValue.getValue());
}
clickButton("Submit");
}
diff --git a/src/org/labkey/test/util/EscapeUtil.java b/src/org/labkey/test/util/EscapeUtil.java
index 48a53d6e2e..d7ba420263 100644
--- a/src/org/labkey/test/util/EscapeUtil.java
+++ b/src/org/labkey/test/util/EscapeUtil.java
@@ -18,6 +18,7 @@
import org.apache.commons.text.StringEscapeUtils;
import org.eclipse.jetty.util.URIUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.labkey.test.params.FieldKey;
import java.net.URLDecoder;
@@ -237,4 +238,34 @@ private static String encodeAppResourcePathPart(String pathPart)
.replace("%28", "(")
.replace("%29", ")");
}
+
+ /**
+ * Form field prefix prepended to all query update form field names.
+ * See {@link org.labkey.api.query.QueryUpdateForm#PREFIX}.
+ */
+ public static final String FORM_FIELD_PREFIX = "quf_";
+ private static final char BACKSLASH = '\\';
+ private static final String SPECIAL_CHARS = BACKSLASH + "\";=,";
+
+ public static String getFormFieldName(String columnName)
+ {
+ return getFormFieldName(columnName, FORM_FIELD_PREFIX);
+ }
+
+ /**
+ * Escapes special characters in a column name to be used as a form field name.
+ * See associated {@link org.labkey.api.query.QueryUpdateForm#getFormFieldName}
+ */
+ public static String getFormFieldName(String columnName, @Nullable String prefix)
+ {
+ StringBuilder fieldName = new StringBuilder();
+ for (char c : columnName.toCharArray())
+ {
+ if (SPECIAL_CHARS.indexOf(c) >= 0)
+ fieldName.append(BACKSLASH);
+ fieldName.append(c);
+ }
+
+ return prefix == null ? fieldName.toString() : prefix + fieldName;
+ }
}
diff --git a/src/org/labkey/test/util/ListHelper.java b/src/org/labkey/test/util/ListHelper.java
index f592f49be0..58a7f33c93 100644
--- a/src/org/labkey/test/util/ListHelper.java
+++ b/src/org/labkey/test/util/ListHelper.java
@@ -113,7 +113,7 @@ protected void setRowData(Map data, boolean validateText)
{
for (String key : data.keySet())
{
- WebElement field = waitForElement(Locator.name("quf_" + key));
+ WebElement field = waitForElement(Locator.name(EscapeUtil.getFormFieldName(key)));
String inputType = field.getAttribute("type");
Object value = data.get(key);
if (value instanceof File)
diff --git a/src/org/labkey/test/util/SampleTypeHelper.java b/src/org/labkey/test/util/SampleTypeHelper.java
index 20175acd72..91f3d5ac2c 100644
--- a/src/org/labkey/test/util/SampleTypeHelper.java
+++ b/src/org/labkey/test/util/SampleTypeHelper.java
@@ -200,7 +200,7 @@ public void insertRow(Map fieldValues)
.clickInsertNewRow();
for (Map.Entry fieldValue : fieldValues.entrySet())
{
- setFormElement(Locator.name("quf_" + fieldValue.getKey()), fieldValue.getValue());
+ setFormElement(Locator.name(EscapeUtil.getFormFieldName(fieldValue.getKey())), fieldValue.getValue());
}
clickButton("Submit");
}