Skip to content
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

test + fix for allControls with forceSelect #226

Merged
merged 5 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $> npm run build
$> npm run build:watch
```

Then to work on a test:
Then to work on a test:
...in terminal 1:

```shell
Expand Down Expand Up @@ -106,6 +106,10 @@ All browser-scope commands (such as `browser.asControl()`) are provided with `/s

Given the continous build watch is running (`npm run build:watch`), hack away at any part!

### instantiation

![wdi5 control instantiation](./wdi5-control-instantiation.png)

## work on a test

recommended approach:
Expand Down Expand Up @@ -160,17 +164,17 @@ some more text
optional 1-line footer
```

Please don't look at the above as restrictions, but rather as conventions: it helps to provide a harmonized codebase, both formatting- and code-style wise. And the coventional commits allow for automtically generating a `CHANGELOG.md` that we all benefit from ("what's new in version ....?").
Please don't look at the above as restrictions, but rather as conventions: it helps to provide a harmonized codebase, both formatting- and code-style wise. And the coventional commits allow for automtically generating a `CHANGELOG.md` that we all benefit from ("what's new in version ....?").
Also, all of this combined aids tremendously in cutting automated releases - so new features or fixes can be published quickly!

Please issue your Pull Requests against the `main` branch of the repository.

## work on the docs

All documentation is written in `markdown` and lives in `/docs`.
All documentation is written in `markdown` and lives in `/docs`.
[`Docsify` is used](https://docsify.js.org/#/) for running the documentation GitHub pages site <https://js-soft.github.io/wdi5>. It can easily be used to also run locally to work and preview the documentation site.

Install it globally: `$> npm i -g docsify-cli`
Install it globally: `$> npm i -g docsify-cli`
Then serve the `docs` dir: `$> docsify serve ./docs`

This will run the documentation site including live reload on <http://localhost:3000>
Expand Down
Binary file added docs/wdi5-control-instantiation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/ui5-js-app/webapp/test/e2e/aggregation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("ui5 aggregation retrieval", () => {

// shorthand getContent()
const content = await page.getContent()
expect(content.length).toBe(2)
expect(content.length).toBe(3)

// shorthand getContent($atIndex)
const firstContentItem = await page.getContent(0)
Expand All @@ -37,7 +37,7 @@ describe("ui5 aggregation retrieval", () => {

// regular getAggregation($name)
const aggregation = await page.getAggregation("content")
expect(aggregation.length).toBe(2)
expect(aggregation.length).toBe(3)

const listIdViaAggregationItem = await aggregation[0].getId()
const vboxIdViaAggregationItem = await aggregation[1].getId()
Expand Down
33 changes: 33 additions & 0 deletions examples/ui5-js-app/webapp/test/e2e/allControlsForce.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const Other = require("./pageObjects/Other")

const oCheckboxSelector = {
forceSelect: true,
selector: {
controlType: "sap.m.CheckBox",
viewName: "test.Sample.view.Other"
}
}

describe("ui5 basic, get all buttons", () => {
before(async () => {
await Other.open()
})

it("test with multiple checkboxes", async () => {
const aCheckbox = await browser.allControls(oCheckboxSelector)

expect(aCheckbox.length).toEqual(9)

for await (let oCheckbox of aCheckbox) {
const selected = await oCheckbox.getSelected()
// console.log(`oCheckbox: ${oCheckbox.getControlInfo().id} isSelected: ${selected} `)
if (!selected) {
await oCheckbox.press()
}
}

for await (let oCheckbox of aCheckbox) {
expect(await oCheckbox.getSelected()).toBeTruthy()
}
})
})
12 changes: 12 additions & 0 deletions examples/ui5-js-app/webapp/view/Other.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
text="add Line Item"
press=".onAddLineItem" />
</VBox>

<List id="PeopleListSelect"
headerText="People List with CheckBox"
items="{/Employees}">
<CustomListItem>
<HBox>
<CheckBox
text="{FirstName} {LastName}"
select="onSelect" />
</HBox>
</CustomListItem>
</List>
</content>
</Page>
</mvc:View>
4 changes: 3 additions & 1 deletion src/lib/wdi5-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class WDI5Control {
* this method is also used wdi5-internally to implement the extended forceSelect option
*/
async renewWebElementReference() {
const newWebElement = (await this.getControl())[0]
const newWebElement = (await this.getControl({ selector: { id: this._domId } }))[0] // added to have a more stable retrieval experience
this._webElement = newWebElement
return newWebElement
}
Expand Down Expand Up @@ -457,6 +457,8 @@ export class WDI5Control {
// only if the result is valid
this._webdriverRepresentation = await $(`//*[@id="${result[2]}"]`)
this._generatedWdioMethods = this._retrieveControlMethods(this._webdriverRepresentation)

this._domId = result[2]
}

this.writeResultLog(result, "getControl()")
Expand Down