Skip to content

Commit

Permalink
feat: enhance browser navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterYinusa committed Jun 12, 2024
1 parent 8898eb5 commit 36ea825
Show file tree
Hide file tree
Showing 57 changed files with 1,618 additions and 2,268 deletions.
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/flask.ExperimentalArea.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/index.PageObject.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.AddNetwork.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Approve.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Completion.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.ConfirmAddSuggestedToken.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.ConfirmRecoveryPhrase.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.ConfirmTransaction.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Connect.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.CreatePassword.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Home.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.ImportWithRecoveryPhrase.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Metametrics.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.PinExtension.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.ReviewRecoveryPhrase.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.SecureYourWallet.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.SignMessage.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.SignatureRequest.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/metamask.Welcome.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.AddNetwork.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.Approve.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.ApproveRequest.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.ConfirmTransaction.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.Connect.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.CreatePassword.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.Import.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.ImportOrConnect.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.ImportSeed.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.ImportSelect.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.Ready.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.RevealSeed.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.SeedBackup.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.SeedVerify.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.SignMessage.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.SignatureRequest.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/rainbow.Welcome.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.AddNetwork.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Approve.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.BackUp.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.ConfirmPassword.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Connect.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.ImportWallet.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Information.html

Large diffs are not rendered by default.

74 changes: 31 additions & 43 deletions docs/classes/zerion.Password.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.RecoveryPhrase.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.SelectWallets.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.SendTransaction.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.SignMessage.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.SignatureRequest.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Success.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Verify.html

Large diffs are not rendered by default.

72 changes: 30 additions & 42 deletions docs/classes/zerion.Welcome.html

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/interface/page/page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { IConfirmation } from '../wallet/confirmation';

export interface IPageObject {
back(): Promise<void>;
backToPage<TPage>(page: new () => TPage): Promise<TPage>;
back<TPage>(page: new () => TPage): Promise<TPage>;
back<TPage>(page?: new () => TPage): Promise<any>;
close(): Promise<void>;
closeAndSwitchToMainWindow<TPage>(page: new () => TPage): Promise<TPage>;
createNewWindow(): Promise<void>;
Expand All @@ -14,14 +15,16 @@ export interface IPageObject {
getWindowHandle(): Promise<any>;
maximize(): Promise<void>;
navigateTo(url: string): Promise<void>;
navigateToPage<TPage>(url: string, page: new () => TPage): Promise<TPage>;
navigateTo<TPage>(url: string, page: new () => TPage): Promise<TPage>;
navigateTo<TPage>(url: string, page?: new () => TPage): Promise<any>;
navigateToPageInNewWindow<TPage>(url: string, page: new () => TPage): Promise<TPage>;
opensInExtension<TPage extends IConfirmation>(page: new () => TPage): Promise<TPage>;
opensInNewWindow(): Promise<void>;
opensInNewWindow<TPage>(page: new () => TPage): Promise<TPage>;
opensInNewWindow<TPage>(page?: new () => TPage): Promise<any>;
refresh(): Promise<void>;
refreshPage<TPage>(page: new () => TPage): Promise<TPage>;
refresh<TPage>(page: new () => TPage): Promise<TPage>;
refresh<TPage>(page?: new () => TPage): Promise<any>;
setSize(width: number, height: number): Promise<void>;
switchBack(): Promise<void>;
switchToFrame(cssLocator: string): Promise<void>;
Expand Down
65 changes: 24 additions & 41 deletions src/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,17 @@ export class PageObject implements IPageObject {
/**
*
* Schedules a command to navigate to the previous URL
* @return {*} {Promise<void>}
* @memberof PageObject
*/
async back(): Promise<void> {
return this.callIfMethodExists('back');
}
/**
*
* Schedules a command to navigate to the previous page
* @template TPage
* @param {new () => TPage} page
* @return {*} {Promise<TPage>}
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
async backToPage<TPage>(page: new () => TPage): Promise<TPage> {
return this.callIfMethodExists('backToPage', [page]);
async back<TPage>(page?: new () => TPage): Promise<any> {
if (page) {
return this.callIfMethodExists('back', [page]);
} else {
return this.callIfMethodExists('back');
}
}
/**
*
Expand Down Expand Up @@ -224,26 +219,19 @@ export class PageObject implements IPageObject {
/**
*
* Schedules a command to navigate to a new URL
* @param {string} url
* @return {*} {Promise<void>}
* @memberof PageObject
*/
async navigateTo(url: string): Promise<void> {
url = this.getFullURL(url);
return this.callIfMethodExists('navigateTo', [url]);
}
/**
*
* Schedules a command to navigate to a new page
* @template TPage
* @param {string} url
* @param {new () => TPage} page
* @return {*} {Promise<TPage>}
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
async navigateToPage<TPage>(url: string, page: new () => TPage): Promise<TPage> {
async navigateTo<TPage>(url: string, page?: new () => TPage): Promise<any> {
url = this.getFullURL(url);
return this.callIfMethodExists('navigateToPage', [url, page]);
if (page) {
return this.callIfMethodExists('navigateTo', [url, page]);
} else {
return this.callIfMethodExists('navigateTo', [url]);
}
}
/**
*
Expand Down Expand Up @@ -284,25 +272,20 @@ export class PageObject implements IPageObject {
return this.callIfMethodExists('opensInNewWindow');
}
}
/**
*
* Schedules a command to refresh the current page
* @return {*} {Promise<void>}
* @memberof PageObject
*/
async refresh(): Promise<void> {
return this.callIfMethodExists('refresh');
}
/**
*
* Schedules a command to refresh the current page
* @template TPage
* @param {new () => TPage} page
* @return {*} {Promise<TPage>}
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
async refreshPage<TPage>(page: new () => TPage): Promise<TPage> {
return this.callIfMethodExists('refreshPage', [page]);
async refresh<TPage>(page?: new () => TPage): Promise<any> {
if (page) {
return this.callIfMethodExists('refresh', [page]);
} else {
return this.callIfMethodExists('refresh');
}
}
/**
*
Expand Down
32 changes: 13 additions & 19 deletions src/playwright/page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ export class PlaywrightPageObject implements IPageObject {
DappDriver.Instance.Page = this.page;
}

async back(): Promise<void> {
async back<TPage>(page?: new () => TPage): Promise<any> {
await this.page.goBack();
}

async backToPage<TPage>(page: new () => TPage): Promise<TPage> {
await this.back();
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async close(): Promise<void> {
Expand Down Expand Up @@ -77,18 +75,16 @@ export class PlaywrightPageObject implements IPageObject {
await this.page.setViewportSize({ width, height });
}

async navigateTo(url: string): Promise<void> {
async navigateTo<TPage>(url: string, page?: new () => TPage): Promise<any> {
await this.page.goto(url);
}

async navigateToPage<TPage>(url: string, page: new () => TPage): Promise<TPage> {
await this.navigateTo(url);
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async navigateToPageInNewWindow<TPage>(url: string, page: new () => TPage): Promise<TPage> {
await this.createNewWindow();
return this.navigateToPage<TPage>(url, page);
return this.navigateTo<TPage>(url, page);
}

async opensInExtension<TPage extends IConfirmation>(page: new () => TPage): Promise<TPage> {
Expand All @@ -104,13 +100,11 @@ export class PlaywrightPageObject implements IPageObject {
}
}

async refresh(): Promise<void> {
async refresh<TPage>(page?: new () => TPage): Promise<any> {
await this.page.reload();
}

async refreshPage<TPage>(page: new () => TPage): Promise<TPage> {
await this.refresh();
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async setSize(width: number, height: number): Promise<void> {
Expand Down
32 changes: 13 additions & 19 deletions src/webdriver/page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ export class WebDriverPageObject implements IPageObject {
this.driver = DappDriver.Instance.Driver as WebDriver;
}

async back(): Promise<void> {
async back<TPage>(page?: new () => TPage): Promise<any> {
await this.driver.navigate().back();
}

async backToPage<TPage>(page: new () => TPage): Promise<TPage> {
await this.back();
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async close(): Promise<void> {
Expand Down Expand Up @@ -67,18 +65,16 @@ export class WebDriverPageObject implements IPageObject {
await this.driver.manage().window().maximize();
}

async navigateTo(url: string): Promise<void> {
async navigateTo<TPage>(url: string, page?: new () => TPage): Promise<any> {
await this.driver.navigate().to(url);
}

async navigateToPage<TPage>(url: string, page: new () => TPage): Promise<TPage> {
await this.navigateTo(url);
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async navigateToPageInNewWindow<TPage>(url: string, page: new () => TPage): Promise<TPage> {
await this.createNewWindow();
return this.navigateToPage<TPage>(url, page);
return this.navigateTo<TPage>(url, page);
}

async opensInExtension<TPage extends IConfirmation>(page: new () => TPage): Promise<TPage> {
Expand All @@ -97,13 +93,11 @@ export class WebDriverPageObject implements IPageObject {
}
}

async refresh(): Promise<void> {
async refresh<TPage>(page?: new () => TPage): Promise<any> {
await this.driver.navigate().refresh();
}

async refreshPage<TPage>(page: new () => TPage): Promise<TPage> {
await this.refresh();
return DappDriver.getPage(page);
if (page) {
return DappDriver.getPage(page);
}
}

async setSize(width: number, height: number): Promise<void> {
Expand Down

0 comments on commit 36ea825

Please sign in to comment.