Permalink
Browse files

framebase: add selects / waitFor / XPath

  • Loading branch information...
zploskey committed Feb 20, 2018
1 parent 92d0d92 commit c7ec94eb6abf7c75b235358f5b5b0b7c654d8dd7
Showing with 40 additions and 10 deletions.
  1. +40 −10 src/FrameBase.re
@@ -2,18 +2,48 @@ type t;

type serializable = Js.Json.t;

[@bs.val] external select : (~selector: string) => Js.Promise.t(ElementHandle.t) = "$";
[@bs.send.pipe : t]
external selectOne :
(~selector: string) => Js.Promise.t(Js.null(ElementHandle.t)) =
"$";

[@bs.send.pipe : t]
external selectAll :
(~selector: string) => Js.Promise.t(array(ElementHandle.t)) =
"$$";

[@bs.send.pipe : t]
external selectXPath : (~xpath: string) => Js.Promise.t(array(ElementHandle.t)) =
"$x";

[@bs.val] external selectAll : (~selector: string) => Js.Promise.t(array(ElementHandle.t)) = "$$";
type selectorOptions = {
.
"visible": Js.nullable(bool),
"hidden": Js.nullable(bool),
"timeout": Js.nullable(float)
};

type selectorOptions = {. "visibile": bool, "timeout": float};
[@bs.obj]
external makeSelectorOptions :
(~visible: Js.boolean=?, ~hidden: Js.boolean=?, ~timeout: float=?, unit) =>
selectorOptions =
"";

let makeSelectorOptions = (~visible=?, ~hidden=?, ~timeout=?, ()) =>
makeSelectorOptions(
~visible=?Util.optBoolToJs(visible),
~hidden=?Util.optBoolToJs(hidden),
~timeout?,
()
);

[@bs.send.pipe : t]
external waitForSelector :
(string, ~options: selectorOptions=?, unit) => Js.Promise.t(unit) =
"";

[@bs.send.pipe : t]
external waitForSelector : (string, ~options: selectorOptions=?, unit) => Js.Promise.t(unit) =
external waitForXPath :
(~xpath: string, ~options: selectorOptions=?, unit) =>
Js.Promise.t(ElementHandle.t) =
"";
/*
$eval(
selector: string,
fn: (...args: Array<Serializable | ElementHandle>) => void
): Promise<Serializable>; */
/* external $eval : selector::string => (fn::fun ...args : array serializable => unit) => promise serializable = "$eval" [@@bs.val]; */

0 comments on commit c7ec94e

Please sign in to comment.