Skip to content

Commit

Permalink
ver. 0.1.29 Function get-sessions now work.
Browse files Browse the repository at this point in the history
  • Loading branch information
kzO8Xekb committed Jan 11, 2023
1 parent 05fa05f commit e2492d8
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 130 deletions.
4 changes: 2 additions & 2 deletions src/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ platform-version, [key]platformVersion: Target platform version. ex. 1.0"
element-id, string, This argument should specify the element ID of the element you wish to operate on.
:get-element-text
element-id, string, This argument should specify the element ID of the element you wish to operate on.
:get-sessions *not tested*
:get-sessions
:get-source
:get-title
:get-window-handle
Expand Down Expand Up @@ -249,7 +249,7 @@ platform-version, [key]platformVersion: Target platform version. ex. 1.0"
width, integer, This argument should specify the new width value.
height, integer, This argument should specify the new height value.
:status
:take-element-screenshot *unwork*
:take-element-screenshot
:take-screenshot
:touch-click
element-id, string, This argument should specify the element ID of the element you wish to operate on.
Expand Down
153 changes: 28 additions & 125 deletions tests/apis-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,92 +36,21 @@
(let
((notepad-session (win-app-driver::create-session))
base)
(subtest "Testing new-session."
(test-api
(funcall
notepad-session
:new-session
:host *win-app-driver-host*
:port *win-app-driver-port*
:app "C:/Windows/System32/notepad.exe")
:app (is
(getf
(win-app-driver::get-value $json)
:|app|)
"C:/Windows/System32/notepad.exe")
:platform-name (is
(getf
(win-app-driver::get-value $json)
:|platformName|)
"Windows")
:path "/session"
:content-length "138"
:value (is
(win-app-driver::get-value $json)
`(:|platformName| "Windows" :|app| "C:/Windows/System32/notepad.exe")))

(setf base (win-app-driver::session-data-base
(funcall
notepad-session
:pandoric-get
'win-app-driver::session)))

; initialized session-data check.
(like
(win-app-driver::session-data-id
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"^" *session-id-regex* "$"))
(is
(win-app-driver::session-data-capabilities
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
"{\"desiredCapabilities\":{\"app\":\"C:/Windows/System32/notepad.exe\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}")
(is
(win-app-driver::session-data-host
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
*win-app-driver-host*)
(is
(win-app-driver::session-data-port
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
*win-app-driver-port*)
(like
(win-app-driver::session-data-base
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"^/session/" *session-id-regex* "$"))
(is
(win-app-driver::session-data-base

(funcall
notepad-session
:new-session
:host *win-app-driver-host*
:port *win-app-driver-port*
:app "C:/Windows/System32/notepad.exe")

(setf base (win-app-driver::session-data-base
(funcall
notepad-session
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"/session/"
(win-app-driver::session-data-id
(funcall
notepad-session
:pandoric-get
'win-app-driver::session)))))
'win-app-driver::session)))

; Find Element
; Find Element
(subtest "Testing find-element."
(test-api
(funcall
Expand Down Expand Up @@ -837,9 +766,6 @@
(win-app-driver::get-value $json)
*base64-regex*)))

; ToDo take-element-screenshot.
; I could not run this in my test environment.

; I could not run this in my test environment.
;(subtest "Testing location."
; (test-api
Expand Down Expand Up @@ -875,40 +801,22 @@
"LANDSCAPE")))

(subtest "Testing get-source."
(test-api
(funcall
notepad-session
:get-source)
:content-length (write-to-string
(+ 1252 (length (win-app-driver::get-value $json))))
:path (concatenate
'string
base
"/source")
:app (ok
(win-app-driver::get-value $json))
:platform-name (ok
(win-app-driver::get-value $json))
:value (ok
(win-app-driver::get-value $json))))

(subtest "Testing get-title."
(test-api
(funcall
notepad-session
:get-title)
:content-length (write-to-string
(+ 92 (length (win-app-driver::get-value $json))))
:path (concatenate
'string
base
"/title")
:app (ok
(win-app-driver::get-value $json))
:platform-name (ok
(win-app-driver::get-value $json))
:value (ok
(win-app-driver::get-value $json))))
(test-api
(funcall
notepad-session
:get-source)
:content-length (write-to-string
(+ 1252 (length (win-app-driver::get-value $json))))
:path (concatenate
'string
base
"/source")
:app (ok
(win-app-driver::get-value $json))
:platform-name (ok
(win-app-driver::get-value $json))
:value (ok
(win-app-driver::get-value $json))))

(subtest "Testing close-window."
(test-api
Expand Down Expand Up @@ -942,11 +850,6 @@
"/click"))))
)

(subtest "Testing delete-session."
(test-api
(funcall notepad-session :delete-session)
:session-id nil
:content-length "12"
:path base))
(funcall notepad-session :delete-session)
)

3 changes: 1 addition & 2 deletions tests/navigation-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
:new-session
:host *win-app-driver-host*
:port *win-app-driver-port*
:app "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
:app-arguments "-private")
:app "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")

(let
((base (win-app-driver::session-data-base
Expand Down
153 changes: 153 additions & 0 deletions tests/session-test.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
;;;; MIT License
;;;;
;;;; Copyright (c) 2016 Microsoft
;;;; Copyright (c) 2022 kzO8Xekb
;;;;
;;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;;; of this software and associated documentation files (the "Software"), to deal
;;;; in the Software without restriction, including without limitation the rights
;;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;;; copies of the Software, and to permit persons to whom the Software is
;;;; furnished to do so, subject to the following conditions:
;;;;
;;;; The above copyright notice and this permission notice shall be included in all
;;;; copies or substantial portions of the Software.
;;;;
;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;;;; SOFTWARE.

(in-package :win-app-driver/tests)

;; NOTE: To run this test file, execute `(asdf:test-system :win-app-driver)' in your Lisp.
; modified from Microsoft sample codes
; https://github.com/microsoft/WinAppDriver/blob/master/Docs/AuthoringTestScripts.md

;// Launch Notepad
;DesiredCapabilities appCapabilities = new DesiredCapabilities();
;appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");
;appCapabilities.SetCapability("appArguments", @"MyTestFile.txt");
;appCapabilities.SetCapability("appWorkingDir", @"C:\MyTestFolder\");
;NotepadSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
(let
((session1 (win-app-driver::create-session))
(session2 (win-app-driver::create-session))
base)
(subtest "Testing new-session."
(test-api
(funcall
session1
:new-session
:host *win-app-driver-host*
:port *win-app-driver-port*
:app "C:/Windows/System32/notepad.exe")
:app (is
(getf
(win-app-driver::get-value $json)
:|app|)
"C:/Windows/System32/notepad.exe")
:platform-name (is
(getf
(win-app-driver::get-value $json)
:|platformName|)
"Windows")
:path "/session"
:content-length "138"
:value (is
(win-app-driver::get-value $json)
`(:|platformName| "Windows" :|app| "C:/Windows/System32/notepad.exe")))

(setf base (win-app-driver::session-data-base
(funcall
session1
:pandoric-get
'win-app-driver::session)))

; initialized session-data check.
(like
(win-app-driver::session-data-id
(funcall
session1
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"^" *session-id-regex* "$"))
(is
(win-app-driver::session-data-capabilities
(funcall
session1
:pandoric-get
'win-app-driver::session))
"{\"desiredCapabilities\":{\"app\":\"C:/Windows/System32/notepad.exe\",\"deviceName\":\"WindowsPC\",\"platformName\":\"Windows\"}}")
(is
(win-app-driver::session-data-host
(funcall
session1
:pandoric-get
'win-app-driver::session))
*win-app-driver-host*)
(is
(win-app-driver::session-data-port
(funcall
session1
:pandoric-get
'win-app-driver::session))
*win-app-driver-port*)
(like
(win-app-driver::session-data-base
(funcall
session1
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"^/session/" *session-id-regex* "$"))
(is
(win-app-driver::session-data-base
(funcall
session1
:pandoric-get
'win-app-driver::session))
(concatenate
'string
"/session/"
(win-app-driver::session-data-id
(funcall
session1
:pandoric-get
'win-app-driver::session)))))

(funcall session2
:new-session
:host *win-app-driver-host*
:port *win-app-driver-port*
:app "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App")

(subtest "Testing get-sessions."
(test-api
(funcall session1 :get-sessions)
:session-id nil
:content-length "1783"
:path "/sessions"
:app (ok
(win-app-driver::get-value $json))
:platform-name (ok
(win-app-driver::get-value $json))
:value (ok
(win-app-driver::get-value $json))))

(subtest "Testing delete-session."
(test-api
(funcall session1 :delete-session)
:session-id nil
:content-length "12"
:path base))

(funcall session2 :delete-session)
)

3 changes: 2 additions & 1 deletion win-app-driver.asd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
;;;; SOFTWARE.

(defsystem "win-app-driver"
:version "0.1.28"
:version "0.1.29"
:author "kzO8Xekb"
:license "MIT"
:depends-on ("alexandria"
Expand Down Expand Up @@ -82,6 +82,7 @@
(:file "main-test")
(:file "api-element-test")
(:file "api-keys-test")
(:file "session-test")
(:file "apis-test")
(:file "actions-test")
(:file "navigation-test")
Expand Down

0 comments on commit e2492d8

Please sign in to comment.