-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: priyanupur <priya.seiji@gmail.com>
- Loading branch information
1 parent
4196c68
commit 6e8e23c
Showing
5 changed files
with
129 additions
and
0 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
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,19 @@ | ||
const Range = require('../elements/range'); | ||
const ElementWrapper = require('./elementWrapper'); | ||
const { firstElement } = require('./helper'); | ||
|
||
class RangeWrapper extends ElementWrapper { | ||
async select(value) { | ||
const elem = await firstElement.apply(this); | ||
return await elem.select(value); | ||
} | ||
async value() { | ||
const elem = await firstElement.apply(this); | ||
return await elem.value(); | ||
} | ||
async elements(retryInterval, retryTimeout) { | ||
let elements = await super.elements(retryInterval, retryTimeout); | ||
return elements.map(element => Range.from(element, this._description)); | ||
} | ||
} | ||
module.exports = RangeWrapper; |
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 { setNavigationOptions } = require('../config'); | ||
const { descEvent } = require('../eventBus'); | ||
const Element = require('./element'); | ||
const { defaultConfig } = require('../config'); | ||
const { highlightElement } = require('./elementHelper'); | ||
|
||
const { doActionAwaitingNavigation } = require('../doActionAwaitingNavigation'); | ||
class Range extends Element { | ||
async select(value) { | ||
if (defaultConfig.headful) { | ||
await highlightElement(this); | ||
} | ||
|
||
function setRange(value) { | ||
this.value = value; | ||
} | ||
|
||
const options = setNavigationOptions({}); | ||
await doActionAwaitingNavigation(options, async () => { | ||
await this.runtimeHandler.runtimeCallFunctionOn(setRange, null, { | ||
nodeId: this.get(), | ||
arg: value, | ||
returnByValue: false, | ||
}); | ||
}); | ||
descEvent.emit('success', 'Selected ' + (value.index || value)); | ||
} | ||
async value() { | ||
function getValue() { | ||
if (this.value) { | ||
return this.value; | ||
} | ||
return this.innerText; | ||
} | ||
const { result } = await this.runtimeHandler.runtimeCallFunctionOn(getValue, null, { | ||
nodeId: this.get(), | ||
}); | ||
return result.value; | ||
} | ||
static from(element, description) { | ||
return new Range(element.get(), description, element.runtimeHandler); | ||
} | ||
} | ||
|
||
module.exports = Range; |
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,39 @@ | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
const chaiAsPromised = require('chai-as-promised'); | ||
chai.use(chaiAsPromised); | ||
let { openBrowser, closeBrowser, goto, range, setConfig } = require('../../lib/taiko'); | ||
let { createHtml, removeFile, openBrowserArgs, resetConfig } = require('./test-util'); | ||
|
||
describe.only('Color picker test', () => { | ||
let filePath; | ||
|
||
before(async () => { | ||
let innerHtml = ` | ||
<div> | ||
<input type="range" id="range-1" name="range" | ||
min="0" max="100" value='2' step="10"> | ||
<label for="volume">Volume</label> | ||
</div> | ||
`; | ||
filePath = createHtml(innerHtml, 'Range'); | ||
await openBrowser(openBrowserArgs); | ||
await goto(filePath); | ||
setConfig({ | ||
waitForNavigation: false, | ||
retryTimeout: 100, | ||
retryInterval: 10, | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
resetConfig(); | ||
await closeBrowser(); | ||
removeFile(filePath); | ||
}); | ||
|
||
it('Set Range value', async () => { | ||
await range({ id: 'range-1' }).select(10); | ||
expect(await range({ id: 'range-1' }).value()).to.be.equal('10'); | ||
}); | ||
}); |