Skip to content

Commit

Permalink
FileUploadPanel: Add backwards compat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-alan committed Dec 20, 2024
1 parent 4fc2366 commit 9cf34d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/org/labkey/test/components/ui/files/FileUploadPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public class FileUploadPanel extends WebDriverComponent<FileUploadPanel.ElementC
{
final WebElement _el;
final WebDriver _driver;
final boolean _backwardsCompat;

public FileUploadPanel(WebElement element, WebDriver driver)
public FileUploadPanel(WebElement element, WebDriver driver, boolean backwardsCompat)
{
_el = element;
_driver = driver;
_backwardsCompat = backwardsCompat;
}

@Override
Expand Down Expand Up @@ -103,10 +105,13 @@ FileInput fileUploadInput()

Locator.XPathLocator attachedFileContainer = Locator.tagWithClass("div", "attached-file__container")
.withChild(Locator.tagWithClass("span", "fa-times-circle"));
Locator.XPathLocator attachedFileContainerOld = Locator.tagWithClass("div", "attached-file--container")
.withChild(Locator.tagWithClass("span", "fa-times-circle"));
WebElement downloadTemplate = Locator.linkWithTitle("Download Template").findWhenNeeded(getDriver());

Locator attachedFileContainer(String fileName)
{
if (_backwardsCompat) return attachedFileContainerOld.withText(fileName);
return attachedFileContainer.withText(fileName);
}

Expand All @@ -120,18 +125,28 @@ WebElement removeBtn(String fileName)

public static class FileUploadPanelFinder extends WebDriverComponentFinder<FileUploadPanel, FileUploadPanelFinder>
{
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "file-upload__container").parent();
private Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "file-upload__container").parent();
private final boolean _backwardsCompat;

public FileUploadPanelFinder(WebDriver driver)
{
super(driver);
_backwardsCompat = false;
}

public FileUploadPanelFinder(WebDriver driver, boolean backwardsCompat)
{
super(driver);
_backwardsCompat = backwardsCompat;
_baseLocator = Locator.tagWithClass("div", "file-upload--container").parent();
}



@Override
protected FileUploadPanel construct(WebElement el, WebDriver driver)
{
return new FileUploadPanel(el, driver);
return new FileUploadPanel(el, driver, _backwardsCompat);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected class ElementCache extends Component<?>.ElementCache
WebElement logoFileInput = Locator.tagWithClass("input", "file-upload__input")
.refindWhenNeeded(this).withTimeout(4000);

WebElement removeBtn = Locator.tagWithClass("span", "file-upload__remove--icon")
WebElement removeBtn = Locator.tagWithClass("span", "attached-file__remove-icon")
.refindWhenNeeded(this).withTimeout(4000);

Locator attachedFile(File file)
Expand Down

0 comments on commit 9cf34d7

Please sign in to comment.