-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiremote support for TestLibrary #489
base: main
Are you sure you want to change the base?
Changes from all commits
e05f8e7
fe8bd83
4e52515
7dc8eb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const { join } = require("path") | ||
|
||
exports.config = { | ||
wdi5: { | ||
screenshotPath: join("app", "incidents", "webapp", "wdi5-test", "__screenshots__"), | ||
logLevel: "verbose", // error | verbose | silent | ||
waitForUI5Timeout: 30000 | ||
}, | ||
//// wdio runner config | ||
specs: [join("webapp", "wdi5-test", "**/Multiremote.test.js")], | ||
// Patterns to exclude. | ||
exclude: [], | ||
//// capabilities ("browser") config | ||
maxInstances: 10, | ||
capabilities: { | ||
one: { | ||
capabilities: { | ||
browserName: "chrome", | ||
acceptInsecureCerts: true, | ||
"goog:chromeOptions": { | ||
args: | ||
process.argv.indexOf("--headless") > -1 | ||
? ["window-size=1440,800", "--headless"] | ||
: process.argv.indexOf("--debug") > -1 | ||
? ["window-size=1920,1280", "--auto-open-devtools-for-tabs"] | ||
: ["window-size=1440,800"] | ||
} | ||
} | ||
}, | ||
two: { | ||
capabilities: { | ||
browserName: "chrome", | ||
acceptInsecureCerts: true, | ||
"goog:chromeOptions": { | ||
args: | ||
process.argv.indexOf("--headless") > -1 | ||
? ["window-size=1440,800", "--headless"] | ||
: process.argv.indexOf("--debug") > -1 | ||
? ["window-size=1920,1280", "--auto-open-devtools-for-tabs"] | ||
: ["window-size=1440,800"] | ||
} | ||
} | ||
} | ||
}, | ||
//// test config | ||
// Level of logging verbosity: trace | debug | info | warn | error | silent | ||
logLevel: "error", | ||
bail: 0, | ||
baseUrl: "http://localhost:8088/index.html#fe-lrop-v4", | ||
|
||
waitforTimeout: 10000, | ||
connectionRetryTimeout: 120000, | ||
connectionRetryCount: 3, | ||
|
||
services: ["chromedriver", "ui5"], | ||
|
||
framework: "mocha", | ||
mochaOpts: { | ||
ui: "bdd", | ||
timeout: 120000 | ||
}, | ||
reporters: ["spec"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
describe("FE basics", () => { | ||
let FioriElementsFacades | ||
before(async () => { | ||
FioriElementsFacades = await browser.fe.initialize({ | ||
onTheMainPage: { | ||
ListReport: { | ||
appId: "sap.fe.demo.incidents", | ||
componentId: "IncidentsList", | ||
entitySet: "Incidents" | ||
} | ||
}, | ||
onTheDetailPage: { | ||
ObjectPage: { | ||
appId: "sap.fe.demo.incidents", | ||
componentId: "IncidentsObjectPage", | ||
entitySet: "Incidents" | ||
} | ||
}, | ||
onTheShell: { | ||
Shell: {} | ||
} | ||
}) | ||
}) | ||
|
||
it("should trigger search on ListReport page on browser one and two", async () => { | ||
await FioriElementsFacades.one.execute((Given, When, Then) => { | ||
Given.onTheMainPage.onFilterBar().iExecuteSearch() | ||
Then.onTheMainPage.onTable().iCheckRows(12) | ||
Then.onTheMainPage.onTable().iCheckRows({ identifier: "inc_0002", title: "Password Reset" }) | ||
When.onTheMainPage.onTable().iPressRow({ identifier: "inc_0002" }) | ||
}) | ||
|
||
await FioriElementsFacades.two.execute((Given, When, Then) => { | ||
Given.onTheMainPage.onFilterBar().iExecuteSearch() | ||
Then.onTheMainPage.onTable().iCheckRows(12) | ||
Then.onTheMainPage.onTable().iCheckRows({ identifier: "inc_0002", title: "Password Reset" }) | ||
When.onTheMainPage.onTable().iPressRow({ identifier: "inc_0002" }) | ||
}) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { initOPA, addToQueue, emptyQueue, loadFELibraries } from "../../client-side-js/testLibrary" | ||
import { Logger as _Logger } from "./Logger" | ||
import { MultiRemoteDriver } from "webdriverio/build/multiremote" | ||
const Logger = _Logger.getInstance() | ||
|
||
const commonFunctions = ["and", "when", "then"] | ||
|
@@ -24,10 +25,19 @@ function createProxy(myObj: any, type: string, methodCalls: any[], pageKeys: str | |
} | ||
export class WDI5FE { | ||
constructor(private appConfig: any, private browserInstance: any) {} | ||
static async initialize(appConfig, browserInstance = browser) { | ||
await loadFELibraries(browserInstance) | ||
await initOPA(appConfig, browserInstance) | ||
return new WDI5FE(appConfig, browserInstance) | ||
static async initialize(appConfig) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar here - why remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we never passed the second parameter to the We could stick to that pattern, but then we have to pass the relevant before(async () => {
FioriElementsFacade = await browser.fe.initialize({appconfig}, browserInstance)
}) I guess we just have to decide what is cleaner |
||
if (browser instanceof MultiRemoteDriver) { | ||
// create for every instance a new facade and load all relevant libraries | ||
return (browser["instances"] as []).reduce(async (facade, browserName) => { | ||
await loadFELibraries(browser[browserName]) | ||
await initOPA(appConfig, browser[browserName]) | ||
return Object.assign(await facade, { [browserName]: new WDI5FE(appConfig, browser[browserName]) }) | ||
}, {}) | ||
} else { | ||
await loadFELibraries(browser) | ||
await initOPA(appConfig, browser) | ||
return new WDI5FE(appConfig, browser) | ||
} | ||
} | ||
|
||
async execute(fnFunction) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm,
browserInstance
is explicitly passed in here → why is it not supposed to be used? IMO thebrowserInstance
helps retain scope within the fn by explicitly not referencing the globalbrowser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we would have to initialize the facade as often as we have defined browsers in the config. That would look like something like this:
We can do that of course, I just don't now if this is the best way