Skip to content

Commit b97f174

Browse files
committed
Escape characters in form field names
1 parent 5869af9 commit b97f174

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/org/labkey/test/pages/assay/AssayImportPage.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
import java.io.File;
3131

32+
import static org.labkey.test.util.EscapeUtil.getTableViewFormFieldName;
33+
3234
public class AssayImportPage extends LabKeyPage<AssayImportPage.Elements>
3335
{
3436
public AssayImportPage(WebDriver driver)
@@ -38,28 +40,28 @@ public AssayImportPage(WebDriver driver)
3840

3941
public AssayImportPage setNamedInputText(String name, String text)
4042
{
41-
WebElement input = Locator.input(name).findElement(getDriver());
43+
WebElement input = Locator.input(getTableViewFormFieldName(name)).findElement(getDriver());
4244
new Input(input, getDriver()).set(text);
4345
return this;
4446
}
4547

4648
public AssayImportPage selectNamedFieldOption(String name, String text)
4749
{
48-
WebElement input = Locator.xpath("//select[@name='" + name +"']").findElement(getDriver());
50+
WebElement input = Locator.tagWithName("select", getTableViewFormFieldName(name)).findElement(getDriver());
4951
new OptionSelect(input).set(text);
5052
return this;
5153
}
5254

5355
public AssayImportPage setNamedTextAreaValue(String name, String text)
5456
{
55-
WebElement input = Locator.textarea(name).findElement(getDriver());
57+
WebElement input = Locator.textarea(getTableViewFormFieldName(name)).findElement(getDriver());
5658
setFormElement(input, text);
5759
return this;
5860
}
5961

6062
public AssayImportPage setFileField(String name, File file)
6163
{
62-
setFormElement(Locator.input(name), file);
64+
setFormElement(Locator.input(getTableViewFormFieldName(name)), file);
6365
return this;
6466
}
6567

@@ -112,7 +114,7 @@ public AssayImportPage selectUploadFileRadioButton()
112114
return StringUtils.trimToNull(text.replace("[remove]", ""));
113115
}
114116

115-
var fileInput = Locator.input(fieldName);
117+
var fileInput = Locator.input(getTableViewFormFieldName(fieldName));
116118
if (isElementPresent(fileInput))
117119
return getFormElement(fileInput);
118120

src/org/labkey/test/util/EscapeUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ public static String getFormFieldName(String columnName)
266266
return getFormFieldName(columnName, FORM_FIELD_PREFIX);
267267
}
268268

269+
public static String getTableViewFormFieldName(String columnName)
270+
{
271+
return getFormFieldName(columnName, null);
272+
}
273+
269274
/**
270275
* Escapes special characters in a column name to be used as a form field name.
271276
* See associated {@link org.labkey.api.query.QueryUpdateForm#getFormFieldName}

0 commit comments

Comments
 (0)