Skip to content

Commit

Permalink
Merge pull request #5 from Exabyte-io/update/SOF-7267
Browse files Browse the repository at this point in the history
SOF-7267: browser timeout
  • Loading branch information
k0stik authored Mar 15, 2024
2 parents 2aa6aed + 8d6222b commit 6f35db9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/js/cypress/Browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export interface BrowserSettings {
}

export class IframeBrowser {
settings: BrowserSettings;
defaultTimeout: number;

#body: Cypress.Chainable;

constructor(settings: BrowserSettings, selector: string) {
this.settings = settings;
constructor(selector: string, defaultTimeout: number) {
this.defaultTimeout = defaultTimeout;

this.#body = cy
.get(selector, { timeout: this.settings.renderTimeoutShort })
.get(selector, { timeout: this.defaultTimeout })
.its("0.contentDocument.body")
.should("not.be.empty", {})
// wraps "body" DOM element to allow
Expand All @@ -25,11 +25,11 @@ export class IframeBrowser {
.then(cy.wrap);
}

waitForVisible(selector: string, timeout = this.settings.renderTimeoutShort) {
waitForVisible(selector: string, timeout = this.defaultTimeout) {
return this.#body.find(selector, { timeout }).should("be.visible");
}

waitForVisibleByXpath(selector: string, timeout = this.settings.renderTimeoutShort) {
waitForVisibleByXpath(selector: string, timeout = this.defaultTimeout) {
return this.#body.xpath(selector, { timeout }).should("be.visible");
}

Expand Down Expand Up @@ -64,8 +64,8 @@ export class Browser {
return cy.visit(path);
}

iframe(selector: string) {
return new IframeBrowser(this.settings, selector);
iframe(selector: string, timeout?: number) {
return new IframeBrowser(selector, timeout || this.settings.renderTimeoutShort);
}

waitForVisible(selector: string, timeout = this.settings.renderTimeoutShort) {
Expand Down

0 comments on commit 6f35db9

Please sign in to comment.