]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/e2e/src/utils/elements.ts
Create screenshots directory when needed
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / elements.ts
... / ...
CommitLineData
1async function getCheckbox (name: string) {
2 const input = $(`my-peertube-checkbox input[id=${name}]`)
3 await input.waitForExist()
4
5 return input.parentElement()
6}
7
8function isCheckboxSelected (name: string) {
9 return $(`input[id=${name}]`).isSelected()
10}
11
12async function selectCustomSelect (id: string, valueLabel: string) {
13 const wrapper = $(`[formcontrolname=${id}] .ng-arrow-wrapper`)
14
15 await wrapper.waitForClickable()
16 await wrapper.click()
17
18 const option = await $$(`[formcontrolname=${id}] .ng-option`).filter(async o => {
19 const text = await o.getText()
20
21 return text.trimStart().startsWith(valueLabel)
22 }).then(options => options[0])
23
24 await option.waitForDisplayed()
25
26 return option.click()
27}
28
29async function findParentElement (
30 el: WebdriverIO.Element,
31 finder: (el: WebdriverIO.Element) => Promise<boolean>
32) {
33 if (await finder(el) === true) return el
34
35 return findParentElement(await el.parentElement(), finder)
36}
37
38export {
39 getCheckbox,
40 isCheckboxSelected,
41 selectCustomSelect,
42 findParentElement
43}