Skip to content
Snippets Groups Projects
Commit 4c2fff02 authored by François Grand's avatar François Grand
Browse files

feat(e2e): add scrollPageToTop()

refs #592
parent 68eaa8cd
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!199Resolve "Incohérence dans les fichiers de session"
......@@ -4,6 +4,7 @@ import { Navbar } from "./navbar.po";
import { PreferencesPage } from "./preferences.po";
import { browser, element, by } from "protractor";
import { testedCalcTypes } from "./tested_calctypes";
import { scrollPageToTop } from "./util.po";
/**
* For all calculators, try to calculate every parameter: check that only one parameter
......@@ -65,7 +66,7 @@ describe("ngHyd − calculate all parameters of all calculators", async () => {
// that the calculable parameters are shown
if (ct === 30 && i > 0) {
// prevents "Element is not clickable at point"
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop();
const inputLink = element(by.css("#pb-data-results-selector .drs-item a"));
await inputLink.click();
}
......
import { by, element, ElementFinder, browser } from "protractor";
import { scrollPageToTop } from "./util.po";
export class CalculatorPage {
......@@ -287,7 +288,7 @@ export class CalculatorPage {
const container = await this.findParentContainer(elt);
// find radio buttons
const button = container.element(by.css("mat-button-toggle.radio_" + mode + " > button"));
await browser.executeScript("window.scrollTo(0, 0);"); // sometimes button slides behind navbar and click() fails
await scrollPageToTop(); // sometimes button slides behind navbar and click() fails
await button.click();
// for "var" mode, close the modal
if (mode === "var") {
......
......@@ -4,6 +4,7 @@ import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { testedCalcTypes } from "./tested_calctypes";
import { scrollPageToTop } from "./util.po";
/**
* Clone calculators
......@@ -48,7 +49,7 @@ describe("ngHyd − clone all calculators with all possible <select> values", ()
const sourceValues = await calcPage.storeAllInputValues();
// clone calculator
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop();
await calcPage.clickCloneCalcButton();
await browser.sleep(300);
......
......@@ -4,6 +4,7 @@ import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { scrollPageToTop } from "./util.po";
/**
* Clone calculators
......@@ -66,7 +67,7 @@ describe("ngHyd − clone a calculator", () => {
await browser.sleep(500);
// otherwise clickCloneCalcButton() fails with "Element is not clickable at point"
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop();
await calcPage.clickCloneCalcButton();
await browser.sleep(500);
......
......@@ -5,6 +5,7 @@ import { browser, by, element } from "protractor";
import { AppPage } from "./app.po";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
import { scrollPageToTop } from "./util.po";
/**
* Clone calculators
......@@ -124,7 +125,7 @@ describe("ngHyd − Passe à Bassins", () => {
await calcButtonCl.click();
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop();
// generate PAB
const genButton = calcPage.getGeneratePabButton();
await genButton.isPresent();
......@@ -182,7 +183,7 @@ describe("ngHyd − Passe à Bassins", () => {
await calcButtonCl.click();
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop();
// create PAB from it, changing modal parameters
const genButton = calcPage.getGeneratePabButton();
await genButton.click();
......
......@@ -5,6 +5,7 @@ import { Navbar } from "./navbar.po";
import { browser, by, element } from "protractor";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
import { scrollPageToTop } from "./util.po";
/**
* Clone calculators
......@@ -124,8 +125,8 @@ describe("Solveur - ", () => {
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// otherwise clickCloneCalcButton() fails with "Element is not clickable at point"
await browser.executeScript("window.scrollTo(0, 0);");
await scrollPageToTop(); // otherwise clickCloneCalcButton() fails with "Element is not clickable at point"
await calcPage.clickCloneCalcButton();
await browser.sleep(500);
......
import { browser } from "protractor";
/**
* scroll page to top
*/
export async function scrollPageToTop() {
await browser.executeScript("window.scrollTo(0, 0);");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment