diff --git a/docs/changelog.md b/docs/changelog.md index 56f3125dd..dfe55be2b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,17 @@ +## 2.0.4 + +* [WebDriver][Protractor][Nightmare][Puppeteer] `grabAttributeFrom` returns an array when multiple elements matched. By @PeterNgTr +* [autoLogin plugin] Fixed merging users config by @nealfennimore +* [autoDelay plugin] Added WebDriver to list of supported helpers by @mattin4d +* [Appium] Fixed using locators in `waitForElement`, `waitForVisible`, `waitForInvisible`. By @eduardofinotti +* [allure plugin] Add tags to allure reports by @Vorobeyko +* [allure plugin] Add skipped tests to allure reports by @Vorobeyko +* Fixed `Logged Test name | [object Object]` when used Data().Scenario(). By @Vorobeyko +* Fixed Data().only.Scenario() to run for all datasets. By @Vorobeyko +* [WebDriver] `attachFile` to work with hidden elements. Fixed in [#1460](https://github.com/Codeception/CodeceptJS/pull/1460) by @tsuemura + + + ## 2.0.3 * [**autoLogin plugin**](https://codecept.io/plugins#autologin) added. Allows to log in once and reuse browser session. When session expires - automatically logs in again. Can persist session between runs by saving cookies to file. diff --git a/docs/webapi/dragSlider.mustache b/docs/webapi/dragSlider.mustache index dbef0cc69..dd2a996f8 100644 --- a/docs/webapi/dragSlider.mustache +++ b/docs/webapi/dragSlider.mustache @@ -5,5 +5,6 @@ For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, I.dragSlider('#slider', 30); I.dragSlider('#slider', -70); ``` -@param field located by label|name|CSS|XPath|strict locator. -@param value position to drag. \ No newline at end of file + +@param locator located by label|name|CSS|XPath|strict locator. +@param offsetX position to drag. \ No newline at end of file diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 64cabb5ba..84cb21748 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1479,6 +1479,29 @@ class WebDriver extends Helper { return sourceEl.dragAndDrop(destEl); } + /** + * {{> ../webapi/dragSlider }} + */ + async dragSlider(locator, offsetX = 0) { + const browser = this.browser; + await this.moveCursorTo(locator); + + // for chrome + if (browser.isW3C) { + return browser.performActions([ + { type: 'pointerDown', button: 0 }, + { + type: 'pointerMove', origin: 'pointer', duration: 1000, x: offsetX, y: 0, + }, + { type: 'pointerUp', button: 0 }, + ]); + } + + await browser.buttonDown(0); + await browser.moveToElement(null, offsetX, 0); + await browser.buttonUp(0); + } + /** * Close all tabs except for the current one. diff --git a/test/data/sandbox/page_slider.html b/test/data/app/view/form/page_slider.php similarity index 100% rename from test/data/sandbox/page_slider.html rename to test/data/app/view/form/page_slider.php diff --git a/test/helper/Puppeteer_test.js b/test/helper/Puppeteer_test.js index e591f9dcb..66169d0bd 100644 --- a/test/helper/Puppeteer_test.js +++ b/test/helper/Puppeteer_test.js @@ -550,7 +550,7 @@ describe('Puppeteer', function () { describe('#dragSlider', () => { it('should drag scrubber to given position', async () => { - await I.amOnPage(`file://${path.resolve(__dirname, '../data/sandbox/page_slider.html')}`); + await I.amOnPage('/form/page_slider'); await I.seeElementInDOM('#slidecontainer input'); const before = await I.grabValueFrom('#slidecontainer input'); await I.dragSlider('#slidecontainer input', 20); diff --git a/test/helper/WebDriver_test.js b/test/helper/WebDriver_test.js index 2f5d6be95..2faa0ff6d 100644 --- a/test/helper/WebDriver_test.js +++ b/test/helper/WebDriver_test.js @@ -638,4 +638,16 @@ describe('WebDriver', function () { it('should attach to invisible input element', () => wd.amOnPage('/form/file') .then(() => wd.attachFile('hidden', '/app/avatar.jpg'))); }); + + + describe('#dragSlider', () => { + it('should drag scrubber to given position', async () => { + await wd.amOnPage('/form/page_slider'); + await wd.seeElementInDOM('#slidecontainer input'); + const before = await wd.grabValueFrom('#slidecontainer input'); + await wd.dragSlider('#slidecontainer input', 20); + const after = await wd.grabValueFrom('#slidecontainer input'); + assert.notEqual(before, after); + }); + }); });