-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get all controls of a specific type (#212)
* wip($$): getControls * feat($$): add getControls/ asControls * feat($$): add getControls/ asControls * refactor: allControls * feat(preformance): change to waitForUi5 with callbacks * refactor: allControls * refactor: pr review Co-authored-by: dominik.feininger <[email protected]>
- Loading branch information
Showing
8 changed files
with
234 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
async function clientSide_allControls(controlSelector) { | ||
controlSelector = await Promise.resolve(controlSelector) // to plug into fluent async api | ||
return await browser.executeAsync((controlSelector, done) => { | ||
const errorHandling = (error) => { | ||
window.wdi5.Log.error("[browser wdi5] ERR: ", error) | ||
done(["error", error.toString()]) | ||
} | ||
|
||
const waitForUI5Options = Object.assign({}, window.wdi5.waitForUI5Options) | ||
if (controlSelector.timeout) { | ||
waitForUI5Options.timeout = controlSelector.timeout | ||
} | ||
|
||
window.wdi5.waitForUI5( | ||
waitForUI5Options, | ||
() => { | ||
window.wdi5.Log.info("[browser wdi5] locating " + JSON.stringify(controlSelector)) | ||
controlSelector.selector = window.wdi5.createMatcher(controlSelector.selector) | ||
window.bridge | ||
.findAllDOMElementsByControlSelector(controlSelector) | ||
.then((domElements) => { | ||
// window.wdi5.Log.info('[browser wdi5] control located! - Message: ' + JSON.stringify(domElement)); | ||
// ui5 control | ||
let returnElements = [] | ||
domElements.forEach((domElement) => { | ||
const ui5Control = window.wdi5.getUI5CtlForWebObj(domElement) | ||
const id = ui5Control.getId() | ||
window.wdi5.Log.info(`[browser wdi5] control with id: ${id} located!`) | ||
const aProtoFunctions = window.wdi5.retrieveControlMethods(ui5Control) | ||
// @type [String, String?, String, "Array of Strings"] | ||
returnElements.push({ domElement: domElement, id: id, aProtoFunctions: aProtoFunctions }) | ||
}) | ||
|
||
done(["success", returnElements]) | ||
}) | ||
.catch(errorHandling) | ||
}, | ||
errorHandling | ||
) | ||
}, controlSelector) | ||
} | ||
|
||
module.exports = { | ||
clientSide_allControls | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const Main = require("./pageObjects/Main") | ||
|
||
const selector = { | ||
wdio_ui5_key: "allButtons", | ||
selector: { | ||
controlType: "sap.m.Button", | ||
viewName: "test.Sample.view.Main" | ||
} | ||
} | ||
|
||
describe("ui5 basic, get all buttons", () => { | ||
before(async () => { | ||
await Main.open() | ||
}) | ||
|
||
it("check number of buttons", async () => { | ||
const buttons = await browser.allControls(selector) | ||
// 7 buttons in view and the panel expand button => 8 | ||
expect(buttons.length).toEqual(8) | ||
}) | ||
|
||
it("no force select", async () => { | ||
const buttons = await browser.allControls(selector) | ||
expect(await buttons[0].getText()).toEqual("to Other view") | ||
}) | ||
|
||
it("with force select", async () => { | ||
const selectorWForce = selector | ||
selectorWForce.forceSelect = true | ||
|
||
const buttons = await browser.allControls(selectorWForce) | ||
expect(await buttons[0].getText()).toEqual("to Other view") | ||
}) | ||
|
||
it("reuse the cached wdi5 controls", async () => { | ||
const buttons = await browser.allControls(selector) | ||
expect(await buttons[0].getText()).toEqual("to Other view") | ||
}) | ||
|
||
it("test webelement", async () => { | ||
const buttons = await browser.allControls(selector) | ||
const webButton = await buttons[0].getWebElement() | ||
expect(webButton).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters