From 68c4194793bc111e54803381fa50b512f6b7d2cc Mon Sep 17 00:00:00 2001 From: Daniel Ziltener Date: Thu, 9 Nov 2023 01:21:50 +0100 Subject: [PATCH] First release FossilOrigin-Name: bd39977c82cb9f2e943b2944ad4443e12748b7f854bb2de2c2d27ee99cd4fc01 --- Makefile | 7 +- tests/run.scm | 20 +- webdriver-impl.scm | 52 ++-- webdriver.egg | 3 + webdriver.html | 542 +++++++++++++++++++++++------------------ webdriver.org | 2 +- webdriver.release-info | 6 +- 7 files changed, 362 insertions(+), 270 deletions(-) diff --git a/Makefile b/Makefile index 1564744..458a38d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ # Tangling and weaving -webdriver.scm webdriver-impl.scm webdriver.html webdriver.egg webdriver.release-info tests/run.scm: webdriver.org +webdriver.scm webdriver-impl.scm webdriver.html webdriver.egg webdriver.release-info tests/run.scm: webdriver.org vendor/htmlize.el emacs --batch \ + --load "~/.config/emacs/early-init.el" \ --load "vendor/htmlize.el" \ --eval "(setq enable-local-variables :all)" \ --eval "(setq org-confirm-babel-evaluate nil)" \ @@ -18,6 +19,10 @@ webdriver.scm webdriver-impl.scm webdriver.html webdriver.egg webdriver.release- echo "" >> "${.ALLSRC:[1]:R}.html" rm "${.ALLSRC:[1]:R}.html.old" +vendor/htmlize.el: + mkdir -p vendor + wget https://raw.githubusercontent.com/hniksic/emacs-htmlize/dd27bc3f26efd728f2b1f01f9e4ac4f61f2ffbf9/htmlize.el -O vendor/htmlize.el + # Extension Rules .scm.so: csc5 -R r7rs -X r7rs -sJ ${.IMPSRC} diff --git a/tests/run.scm b/tests/run.scm index ccf84bb..20200b6 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -25,7 +25,18 @@ ;; #+name: prep-geckodriver-test ;; [[file:../webdriver.org::prep-geckodriver-test][prep-geckodriver-test]] - +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> +<> ;; prep-geckodriver-test ends here @@ -33,6 +44,7 @@ ;; #+name: wd-session-test ;; [[file:../webdriver.org::wd-session-test][wd-session-test]] +<> (test-group "session" (let ((browser (new-WebDriver ))) (test "Initial state" #f (slot-value browser 'session-id)) @@ -46,6 +58,8 @@ ;; #+name: wd-url-test ;; [[file:../webdriver.org::wd-url-test][wd-url-test]] +<> +<> (test-group "url" (let ((browser (new-WebDriver ))) (test "Initial state" #f (slot-value browser 'session-id)) @@ -55,3 +69,7 @@ (url browser))) (terminate browser))) ;; wd-url-test ends here + +;; [[file:../webdriver.org::*About This Egg][About This Egg:2]] +(test-exit) +;; About This Egg:2 ends here diff --git a/webdriver-impl.scm b/webdriver-impl.scm index 0fceb42..4b1f4d6 100644 --- a/webdriver-impl.scm +++ b/webdriver-impl.scm @@ -16,9 +16,7 @@ ) ;; Dependencies:4 ends here - - -;; * Error Conditions +;; Error Conditions ;; #+name: wd-exception @@ -97,9 +95,7 @@ ) ;; conditions ends here - - -;; * WebDriver +;; WebDriver ;; The core element of the library is the ~~ class and its subclasses. The class has the following fields: @@ -156,9 +152,7 @@ instance)) ;; webdriver-init ends here - - -;; ** Geckodriver +;; Geckodriver ;; The Geckodriver is used to control Firefox. @@ -201,11 +195,7 @@ (alist-ref/default result 'value result)) ;; geckodriver-postprocess ends here - - -;; * WebDriver API - -;; ** Communication +;; Communication ;; Data is sent to the API via a central class method. For convenience, there is a ~send-with-session~ variant that automatically adds the session id. @@ -229,9 +219,7 @@ (send instance data (string-append "session/" (slot-value instance 'session-id) "/" uri) method)) ;; wd-send ends here - - -;; ** Session management +;; Session management ;; Session management is very simple. There is just one method to initialize a new session. Everything else is handled automatically. @@ -254,18 +242,7 @@ (set! (slot-value instance 'session-id) #f)) ;; wd-term-session ends here - - -;; #+RESULTS: wd-session-test -;; : -- testing session ----------------------------------------------------------- -;; : Initial state ........................................................ [ PASS] -;; : Session id check ..................................................... [ PASS] -;; : Session id after termination ......................................... [ PASS] -;; : 3 tests completed in 3.788 seconds. -;; : 3 out of 3 (100%) tests passed. -;; : -- done testing session ------------------------------------------------------ - -;; ** API Access Methods +;; API Access Methods ;; #+name: wd-url @@ -338,7 +315,7 @@ (send-with-session instance `((script . ,script) (args . ,args)) "execute/sync" 'POST)) ;; API Access Methods:12 ends here - +;; Timeouts ;; The following timeouts are defined: @@ -361,6 +338,9 @@ (implicit . ,(slot-value instance 'implicit)))) ;; Timeouts:2 ends here +;; Setting and getting timeouts + + ;; [[file:webdriver.org::*Setting and getting timeouts][Setting and getting timeouts:1]] (define-method (set-timeouts (instance ) (timeouts )) (send-with-session instance (extract timeouts) "timeouts" 'POST)) @@ -373,6 +353,9 @@ 'implicit (alist-ref result 'implicit)))) ;; Setting and getting timeouts:1 ends here +;; Element Class + + ;; [[file:webdriver.org::*Element Class][Element Class:1]] (define-class () ((driver #f) @@ -386,6 +369,9 @@ method)) ;; Element Class:2 ends here +;; Location Strategies + + ;; [[file:webdriver.org::*Location Strategies][Location Strategies:1]] (define css-selector "css selector") (define link-text "link text") @@ -394,6 +380,9 @@ (define xpath "xpath") ;; Location Strategies:1 ends here +;; Accessor Methods + + ;; [[file:webdriver.org::*Accessor Methods][Accessor Methods:1]] (define-method (find-element (instance ) strategy selector) (let ((result (send-with-session instance `((using . ,strategy) (value . ,selector)) "element" 'POST))) @@ -426,6 +415,9 @@ result))) ;; Accessor Methods:4 ends here +;; Working with Elements + + ;; [[file:webdriver.org::*Working with Elements][Working with Elements:1]] (define-method (attribute (instance ) attribute) (let ((result (send-with-session instance #f diff --git a/webdriver.egg b/webdriver.egg index d81e8bc..e091a9a 100644 --- a/webdriver.egg +++ b/webdriver.egg @@ -1,3 +1,6 @@ +;; About This Egg + + ;; [[file:webdriver.org::*About This Egg][About This Egg:1]] ;; -*- scheme -*- ((author "Daniel Ziltener") diff --git a/webdriver.html b/webdriver.html index 88c75ce..08eed5f 100644 --- a/webdriver.html +++ b/webdriver.html @@ -1,16 +1,4 @@ - - - - - - - -Webdriver implementation in Chicken Scheme - - -