File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ A release with an intentional breaking changes is marked with:
19
19
// (adjust these in publish.clj as you see fit)
20
20
== Unreleased
21
21
22
+ * Changes
23
+ ** {issue}679[#679]: Add `new-window` function that exposes WebDriver's New Window endpoint. ({person}dgr[@dgr])
24
+
22
25
== v1.1.42 - 2024-09-27 [[v1.1.42]]
23
26
24
27
* Changes
Original file line number Diff line number Diff line change 92
92
- [[get-window-size]] [[set-window-size]]
93
93
- [[maximize]]
94
94
- [[switch-window]] [[switch-window-next]]
95
- - [[close-window]]
95
+ - [[new-window]] [[ close-window]]
96
96
97
97
**Frames**
98
98
- [[switch-frame]] [[switch-frame-first]] [[switch-frame-parent]] [[switch-frame-top]] [[with-frame]]
372
372
(recur hs)))]
373
373
(switch-window driver next-handle)))
374
374
375
+ (defn new-window
376
+ " Have `driver` create a new window. The `window-type-hint` parameter
377
+ must be either `:tab` or `:window` and specifies the type of window
378
+ that is desired, if supported by the browser. If successful, return
379
+ a map with keys `:handle` indicating the new window handle and
380
+ `:type` indicating the type of window that was actually
381
+ created (either `:tab` or `:window`).
382
+
383
+ https://www.w3.org/TR/webdriver2/#dfn-new-window"
384
+ [driver window-type-hint]
385
+ (if (#{:tab :window } window-type-hint)
386
+ (-> (execute {:driver driver
387
+ :method :post
388
+ :path [:session (:session driver) :window :new ]
389
+ :data {:type window-type-hint}})
390
+ :value
391
+ (update :type keyword))
392
+ (throw+ {:type :etaoin/argument
393
+ :message " Argument `window-type-hint` must be either `:tab` or `:window`."
394
+ :window-type-hint window-type-hint})))
395
+
375
396
(defn close-window
376
397
" Have `driver` close current browser window.
377
398
On last window close, closes the session.
Original file line number Diff line number Diff line change 637
637
(is (not= width width'))
638
638
(is (not= height height'))))))
639
639
640
+ (deftest test-new-window
641
+ (is (= 1 (count (e/get-window-handles *driver*))))
642
+ (let [initial-window (e/get-window-handle *driver*)
643
+ new-windows (for [_ (range 3 )]
644
+ (-> (e/new-window *driver* :tab )
645
+ :handle ))
646
+ windows (into #{initial-window} new-windows)]
647
+ (is (= 4 (count (e/get-window-handles *driver*))))
648
+ (is (= windows (set (e/get-window-handles *driver*))))))
649
+
640
650
(deftest test-switch-window
641
651
(let [init-handle (e/get-window-handle *driver*)
642
652
init-url (e/get-url *driver*)]
You can’t perform that action at this time.
0 commit comments