Skip to content

Commit

Permalink
screenobject(update): use enter key to save create folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Oct 23, 2023
1 parent 0304066 commit 1c69014
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tests/screenobjects/files/FilesScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,28 +364,32 @@ export default class FilesScreen extends UplinkMainScreen {

async createFolder(name: string) {
await this.clickOnCreateFolder();
const filesInfoCurrentSizeLabel = await this.filesInfoCurrentSizeLabel;
const inputFolderFileName = await this.inputFolderFileName;
await inputFolderFileName.waitForExist();
await inputFolderFileName.setValue(name);
// Retry typing if appium fails on type
const inputValue = await inputFolderFileName.getText();
if (inputValue !== name) {
await this.createFolder(name);
}
await this.typeOnFileFolderNameInput(name);
await this.pressEnterOnInputFileFolderName();
// If name was typed correctly, continue with method execution
await filesInfoCurrentSizeLabel.click();
const newFolder = await this.getLocatorOfFolderFile(name);
const newFolderElement = await this.instance.$(newFolder);
await newFolderElement.waitForExist();
}

async typeOnFileFolderNameInput(name: string) {
const inputFolderFileName = await this.inputFolderFileName;
await inputFolderFileName.waitForExist();
await inputFolderFileName.clearValue();
await inputFolderFileName.setValue(name);
const filesInfoCurrentSizeLabel = await this.filesInfoCurrentSizeLabel;
await filesInfoCurrentSizeLabel.click();
const currentValue = await inputFolderFileName.getText();
if (currentValue !== name) {
await this.typeOnFileFolderNameInput(name);
}
}

async pressEnterOnInputFileFolderName() {
const inputFolderFileName = await this.inputFolderFileName;
const currentDriver = await this.getCurrentDriver();
if (currentDriver === MACOS_DRIVER) {
await inputFolderFileName.addValue("\n");
} else if (currentDriver === WINDOWS_DRIVER) {
await inputFolderFileName.addValue("\uE007");
}
}

async downloadFile(filename: string) {
Expand Down
6 changes: 6 additions & 0 deletions tests/specs/03-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ export default async function files() {

// Attempt to set the new name for the file as app-macos.zip and wait for error toast notification to be closed
await filesScreenFirstUser.typeOnFileFolderNameInput("app-macos");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();
await filesScreenFirstUser.waitUntilNotificationIsClosed();

// Type the previous filename for app-macos (1) so it can keep the original name. Ensure that file still exists in Screen
await filesScreenFirstUser.typeOnFileFolderNameInput("app-macos (1)");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();
await filesScreenFirstUser.validateFileOrFolderExist("app-macos (1).zip");
});

Expand All @@ -261,10 +263,12 @@ export default async function files() {
// Click on Create Folder and type the existing folder name "testfolder01"
await filesScreenFirstUser.clickOnCreateFolder();
await filesScreenFirstUser.typeOnFileFolderNameInput("testfolder01");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();

// Wait until error toast notification is closed and type a valid name for the new folder
await filesScreenFirstUser.waitUntilNotificationIsClosed();
await filesScreenFirstUser.typeOnFileFolderNameInput("testfolder02");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();

// Ensure that new folder was created with name "testfolder02"
await filesScreenFirstUser.validateFileOrFolderExist("testfolder02");
Expand All @@ -277,10 +281,12 @@ export default async function files() {

// Attempt to change the name of testfolder02 to existing folder name testfolder01
await filesScreenFirstUser.typeOnFileFolderNameInput("testfolder01");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();

// Wait until error toast notification is closed and type the existing folder name for testfolder02
await filesScreenFirstUser.waitUntilNotificationIsClosed();
await filesScreenFirstUser.typeOnFileFolderNameInput("testfolder02");
await filesScreenFirstUser.pressEnterOnInputFileFolderName();
await filesScreenFirstUser.validateFileOrFolderExist("testfolder02");
});
}

0 comments on commit 1c69014

Please sign in to comment.