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: Created Nov. 6, 2018, 8:32 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« test/browsers/firefox.js ('K') | « 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 Promise.all([
76 element.getDriver().takeScreenshot().then(imageFromBase64), 76 element.getDriver().takeScreenshot().then(imageFromBase64),
77 element.getSize() 77 element.getRect()
Sebastian Noack 2018/11/06 09:02:33 You might want to use the loc variable (and maybe
hub 2018/11/07 17:13:37 Done.
78 ]).then(([img, size]) => 78 ]).then(([img, size]) =>
79 img.crop(x, y, size.width, size.height) 79 img.crop(x, y, size.width, size.height)
80 ); 80 );
81 }) 81 })
82 ) 82 )
83 ).then(img => img.bitmap); 83 ).then(img => img.bitmap);
84 } 84 }
85 85
86 function getSections(driver) 86 function getSections(driver)
87 { 87 {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 `) 246 `)
247 ).then(([added, err]) => 247 ).then(([added, err]) =>
248 { 248 {
249 if (err) 249 if (err)
250 throw err; 250 throw err;
251 assert.ok(added, "subscription added"); 251 assert.ok(added, "subscription added");
252 }) 252 })
253 ) 253 )
254 ); 254 );
255 }); 255 });
OLDNEW
« test/browsers/firefox.js ('K') | « test/browsers/firefox.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld