querySelector interface.
Showing
1 changed file
with
26 additions
and
0 deletions
... | @@ -936,6 +936,32 @@ Casper.prototype.open = function open(location, settings) { | ... | @@ -936,6 +936,32 @@ Casper.prototype.open = function open(location, settings) { |
936 | }; | 936 | }; |
937 | 937 | ||
938 | /** | 938 | /** |
939 | * Retrieves a DOM element matching the provided CSS3 selector. | ||
940 | * | ||
941 | * @param String selector A CSS3 selector | ||
942 | * @return HTMLElement The requested DOM element | ||
943 | */ | ||
944 | Casper.prototype.querySelector = function querySelector(selector) { | ||
945 | "use strict"; | ||
946 | return this.evaluate(function _evaluate(selector) { | ||
947 | return window.querySelector(selector); | ||
948 | }, { selector: selector }); | ||
949 | }; | ||
950 | |||
951 | /** | ||
952 | * Retrieves a NodeList of DOM elements matching the provided CSS3 selector. | ||
953 | * | ||
954 | * @param String selector A CSS3 selector | ||
955 | * @return HTMLElement[] The requested NodeList of DOM elements | ||
956 | */ | ||
957 | Casper.prototype.querySelectorAll = function querySelectorAll(selector) { | ||
958 | "use strict"; | ||
959 | return this.evaluate(function _evaluate(selector) { | ||
960 | return window.querySelectorAll(selector); | ||
961 | }, { selector: selector }); | ||
962 | }; | ||
963 | |||
964 | /** | ||
939 | * Reloads current page. | 965 | * Reloads current page. |
940 | * | 966 | * |
941 | * @param Function then a next step function | 967 | * @param Function then a next step function | ... | ... |
-
Please register or sign in to post a comment