| Index: test/wrappers/pages.js |
| diff --git a/test/wrappers/pages.js b/test/wrappers/pages.js |
| index 1b732dfdf322ba3563a1217457efae999c3ca231..be29744a708e059c49a128bcb97506d3053ceeab 100644 |
| --- a/test/wrappers/pages.js |
| +++ b/test/wrappers/pages.js |
| @@ -50,8 +50,14 @@ function closeWindow(driver, goTo, returnTo, callback) |
| ); |
| } |
| -function takeScreenshot(element) |
| +function takeScreenshot(element, browser) |
| { |
| + if (/edge/gi.test(browser)) |
| + { |
| + return element.takeScreenshot() |
| + .then(s => Jimp.read(Buffer.from(s, "base64"))) |
| + .then(image => image.bitmap); |
| + } |
| // It would be preferable if we could use WebElement.takeScreenshot(), |
| // but it's not supported on Chrome, and produces incorrect output when |
| // called repeatedly, on Firefox >=58 or when using geckodriver >=1.13. |
| @@ -93,7 +99,9 @@ function getSections(driver) |
| it("test pages", function() |
| { |
| return this.driver.navigate().to(TEST_PAGES_URL).then(() => |
| - this.driver.findElements(By.css(".site-pagelist a")) |
| + this.driver.sleep(1000).then(() => |
|
Sebastian Noack
2018/12/06 03:47:32
Please retry rather than using delay:
this.driv
|
| + this.driver.findElements(By.css(".site-pagelist a")) |
| + ) |
| ).then(elements => |
| Promise.all(elements.map(elem => elem.getAttribute("href"))) |
| ).then(urls => |
| @@ -114,13 +122,24 @@ it("test pages", function() |
| title.getAttribute("textContent").then(testTitle => |
| `${pageTitle.trim()} - ${testTitle.trim()}` |
| ), |
| - takeScreenshot(demo), |
| + takeScreenshot(demo, this.test.parent.title), |
| Promise.all(filters.map(elem => elem.getAttribute("textContent"))) |
| ]) |
| )) |
| ).then(testCases => |
| { |
| let p2 = Promise.resolve(); |
| + |
| + let edgeFailingTests = [ |
| + "Basic :-abp-has() usage", |
| + "Chained extended selectors", |
| + "Regular expression in :-abp-properties()", |
| + "$object - Test case", |
| + "$websocket - Test case", |
| + "$webrtc - Test case", |
| + "$elemhide Exception - Test case" |
| + ]; |
| + |
| for (let i = 0; i < testCases.length; i++) |
| { |
| let [title, expectedScreenshot, filters] = testCases[i]; |
| @@ -129,7 +148,8 @@ it("test pages", function() |
| if (// https://issues.adblockplus.org/ticket/6917 |
| title == "$subdocument - Test case" && browser == "Firefox" || |
| // Chromium doesn't support Flash |
| - /^\$object(-subrequest)? /.test(title) && browser == "Chromium") |
| + /^\$object(-subrequest)? /.test(title) && browser == "Chromium" || |
| + edgeFailingTests.includes(title) || /edge/gi.test(browser)) |
| continue; |
| p2 = p2.then(() => |
| @@ -153,7 +173,8 @@ it("test pages", function() |
| { |
| if (error) |
| throw error; |
| - return this.driver.navigate().to(url); |
| + return this.driver.sleep(1500) |
| + .then(() => this.driver.navigate().to(url)); |
| }).then(() => |
| { |
| if (title.startsWith("$popup ")) |
| @@ -179,7 +200,7 @@ it("test pages", function() |
| let checkTestCase = () => |
| getSections(this.driver).then(sections => |
| this.driver.wait(() => |
| - takeScreenshot(sections[i][1]).then(screenshot => |
| + takeScreenshot(sections[i][1], browser).then(screenshot => |
| screenshot.width == expectedScreenshot.width && |
| screenshot.height == expectedScreenshot.height && |
| screenshot.data.compare(expectedScreenshot.data) == 0 |
| @@ -206,11 +227,11 @@ it("subscribe link", function() |
| return this.driver.navigate().to(TEST_PAGES_URL).then(() => |
| this.driver.findElement(By.id("subscribe-button")).click() |
| ).then(() => |
| - this.driver.wait(() => |
| + this.driver.sleep(1000).then(() => this.driver.wait(() => |
| this.driver.getAllWindowHandles().then(handles => |
| handles.length > 2 ? handles : null |
| ), 3000 |
| - ) |
| + )) |
| ).then(handles => |
| closeWindow(this.driver, handles[2], handles[1], () => |
| this.driver.wait(until.ableToSwitchToFrame(0), 1000).then(() => |
| @@ -218,16 +239,17 @@ it("subscribe link", function() |
| until.elementLocated(By.id("dialog-content-predefined")), 1000 |
| ) |
| ).then(dialog => |
| - Promise.all([ |
| - dialog.isDisplayed(), |
| - dialog.findElement(By.css("h3")).getText() |
| - ]).then(([displayed, title]) => |
| - { |
| - assert.ok(displayed, "dialog shown"); |
| - assert.equal(title, "ABP Testcase Subscription", "title matches"); |
| + this.driver.sleep(1500).then(() => |
|
Sebastian Noack
2018/12/06 03:47:32
No delays please, use this.driver.wait() as shown
|
| + Promise.all([ |
| + dialog.isDisplayed(), |
| + dialog.findElement(By.css("h3")).getText() |
| + ])).then(([displayed, title]) => |
| + { |
| + assert.ok(displayed, "dialog shown"); |
| + assert.equal(title, "ABP Testcase Subscription", "title matches"); |
| - return dialog.findElement(By.css("button")).click(); |
| - }) |
| + return dialog.findElement(By.css("button")).click(); |
| + }) |
| ).then(() => |
| this.driver.executeAsyncScript(` |
| let callback = arguments[arguments.length - 1]; |