diff --git a/lib/locators.js b/lib/locators.js
index 36e391bde..db29a8790 100644
--- a/lib/locators.js
+++ b/lib/locators.js
@@ -428,4 +428,27 @@ ProtractorBy.prototype.options = function(optionsDescriptor) {
};
};
+/**
+ * Find an element by css selector within the Shadow DOM.
+ *
+ * @alias by.deepCss(selector)
+ * @view
+ *
+ *
+ * <"shadow tree">
+ *
+ * <"shadow tree">
+ *
+ * >
+ * >
+ *
+ * @example
+ * spans = element.all(by.deepCss('span'));
+ * expect(spans.count()).toEqual(3);
+ */
+ProtractorBy.prototype.deepCss = function(selector) {
+ // return webdriver.By.css('* >>> ' + selector);
+ return webdriver.By.css('* /deep/ ' + selector);
+};
+
exports.ProtractorBy = ProtractorBy;
diff --git a/spec/basic/locators_spec.js b/spec/basic/locators_spec.js
index 8899bfe24..930d87856 100644
--- a/spec/basic/locators_spec.js
+++ b/spec/basic/locators_spec.js
@@ -355,6 +355,29 @@ describe('locators', function() {
});
});
+ describe('by deep css', function() {
+ beforeEach(function() {
+ browser.get('index.html#/shadow');
+ });
+
+ it('should find items inside the shadow DOM', function() {
+ var parentHeading = element(by.deepCss('.parentshadowheading'));
+ var olderChildHeading = element(by.deepCss('.oldershadowheading'));
+ var youngerChildHeading = element(by.deepCss('.youngershadowheading'));
+
+ expect(parentHeading.isPresent()).toBe(true);
+ expect(olderChildHeading.isPresent()).toBe(true);
+ expect(youngerChildHeading.isPresent()).toBe(true);
+
+ expect(parentHeading.getText()).toEqual('Parent');
+ expect(olderChildHeading.getText()).toEqual('Older Child');
+ expect(youngerChildHeading.getText()).toEqual('Younger Child');
+
+ expect(element(by.deepCss('.originalcontent')).getText())
+ .toEqual('original content');
+ });
+ });
+
it('should determine if an element is present', function() {
expect(browser.isElementPresent(by.binding('greet'))).toBe(true);
expect(browser.isElementPresent(by.binding('nopenopenope'))).toBe(false);
diff --git a/testapp/alt_root_index.html b/testapp/alt_root_index.html
index 38c4ece8c..9f1918e2a 100644
--- a/testapp/alt_root_index.html
+++ b/testapp/alt_root_index.html
@@ -39,6 +39,7 @@
+