Skip to content

Commit e2bf651

Browse files
author
John Doherty
committed
added helpers.getPseudoElementBeforeValue and helpers.getPseudoElementAfterValue methods
1 parent 3d283ef commit e2bf651

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

README.MD

+6
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ helpers.waitUntilAttributeExists('html', 'data-busy', 5000);
264264

265265
// wait until a HTML attribute no longer exists
266266
helpers.waitUntilAttributeDoesNotExists('html', 'data-busy', 5000);
267+
268+
// get the content value of a :before pseudo element
269+
helpers.getPseudoElementBeforeValue('body header');
270+
271+
// get the content value of a :after pseudo element
272+
helpers.getPseudoElementAfterValue('body header');
267273
```
268274

269275
### Visual Comparison

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-cucumber-js",
3-
"version": "1.5.7",
3+
"version": "1.5.8",
44
"description": "JavaScript browser automation framework using official selenium-webdriver and cucumber-js",
55
"main": "index.js",
66
"scripts": {

runtime/helpers.js

+44-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,49 @@ module.exports = {
215215
});
216216

217217
}, timeout, timeoutMessage);
218-
}
218+
},
219+
220+
/**
221+
* Get the content value of a :before pseudo element
222+
* @param {string} cssSelector - css selector of element to inspect
223+
* @returns {Promise} executes .then with value
224+
* @example
225+
* helpers.getPseudoElementBeforeValue('body header').then(function(value) {
226+
* console.log(value);
227+
* });
228+
*/
229+
getPseudoElementBeforeValue: function(cssSelector) {
219230

231+
function getBeforeContentValue(qs) {
232+
233+
var el = document.querySelector(qs);
234+
var styles = el ? window.getComputedStyle(el, ':before') : null;
235+
236+
return styles ? styles.getPropertyValue('content') : '';
237+
}
238+
239+
return driver.executeScript(getBeforeContentValue, cssSelector);
240+
},
241+
242+
/**
243+
* Get the content value of a :after pseudo element
244+
* @param {string} cssSelector - css selector of element to inspect
245+
* @returns {Promise} executes .then with value
246+
* @example
247+
* helpers.getPseudoElementAfterValue('body header').then(function(value) {
248+
* console.log(value);
249+
* });
250+
*/
251+
getPseudoElementAfterValue: function(cssSelector) {
252+
253+
function getAfterContentValue(qs) {
254+
255+
var el = document.querySelector(qs);
256+
var styles = el ? window.getComputedStyle(el, ':after') : null;
257+
258+
return styles ? styles.getPropertyValue('content') : '';
259+
}
260+
261+
return driver.executeScript(getAfterContentValue, cssSelector);
262+
}
220263
};

0 commit comments

Comments
 (0)