Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/wrappers/pages.js

Issue 29938555: Noissue - Upgrade to selenium-webdriver 4.0.0-alpha (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Updated README Created Nov. 9, 2018, 8:16 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/browsers/firefox.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 function takeScreenshot(element) 56 function takeScreenshot(element)
57 { 57 {
58 return element.takeScreenshot().then( 58 return element.takeScreenshot().then(
59 imageFromBase64, 59 imageFromBase64,
60 60
61 // Chrome doesn't support taking screenshots of individual elements. So as 61 // Chrome doesn't support taking screenshots of individual elements. So as
62 // a workaround, we scroll to the position of the element, take a screenshot 62 // a workaround, we scroll to the position of the element, take a screenshot
63 // of the viewport and crop it to the size and position of our element. 63 // of the viewport and crop it to the size and position of our element.
64 // This is not guaranteed to work on other browsers (mostly because 64 // This is not guaranteed to work on other browsers (mostly because
65 // the behavior of Driver.takeScreenshot() may vary across browsers). 65 // the behavior of Driver.takeScreenshot() may vary across browsers).
66 () => element.getLocation().then(loc => 66 () => element.getRect().then(loc =>
67 element.getDriver().executeScript(` 67 element.getDriver().executeScript(`
68 window.scrollTo(${loc.x}, ${loc.y}); 68 window.scrollTo(${loc.x}, ${loc.y});
69 return [window.scrollX, window.scrollY]; 69 return [window.scrollX, window.scrollY];
70 `).then(result => 70 `).then(result =>
71 { 71 {
72 let x = loc.x - result[0]; 72 let x = loc.x - result[0];
73 let y = loc.y - result[1]; 73 let y = loc.y - result[1];
74 74
75 return Promise.all([ 75 return element.getDriver().takeScreenshot().then(
76 element.getDriver().takeScreenshot().then(imageFromBase64), 76 imageFromBase64).then(img => img.crop(x, y, loc.width, loc.height));
77 element.getSize()
78 ]).then(([img, size]) =>
79 img.crop(x, y, size.width, size.height)
80 );
81 }) 77 })
82 ) 78 )
83 ).then(img => img.bitmap); 79 ).then(img => img.bitmap);
84 } 80 }
85 81
86 function getSections(driver) 82 function getSections(driver)
87 { 83 {
88 return driver.findElements(By.css("section")).then(elements => 84 return driver.findElements(By.css("section")).then(elements =>
89 Promise.all(elements.map(e => 85 Promise.all(elements.map(e =>
90 Promise.all([ 86 Promise.all([
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 `) 242 `)
247 ).then(([added, err]) => 243 ).then(([added, err]) =>
248 { 244 {
249 if (err) 245 if (err)
250 throw err; 246 throw err;
251 assert.ok(added, "subscription added"); 247 assert.ok(added, "subscription added");
252 }) 248 })
253 ) 249 )
254 ); 250 );
255 }); 251 });
OLDNEW
« no previous file with comments | « test/browsers/firefox.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld