getting processes closer
parent
e0bf4848ff
commit
58da422a11
|
@ -1,4 +1,5 @@
|
|||
USING: kernel http http.client http.server io.sockets io.streams.byte-array io.pathnames io.encodings.binary io.encodings.string io.encodings.utf8 io.launcher accessors urls parser effects.parser words arrays sequences quotations json.reader json.writer formatting assocs namespaces present hashtables words.symbol combinators lexer calendar prettyprint.backend base64 images.png destructors math.parser threads ;
|
||||
|
||||
USING: prettyprint ;
|
||||
|
||||
IN: web-driver
|
||||
|
@ -14,7 +15,7 @@ CONSTANT: partial-link-text-location-strategy "partial link text"
|
|||
CONSTANT: tag-name-location-strategy "tag name"
|
||||
CONSTANT: xpath-location-strategy "xpath"
|
||||
|
||||
TUPLE: web-driver-session remote-url session-id capabilities ;
|
||||
TUPLE: web-driver-session remote-url web-driver-process session-id capabilities ;
|
||||
TUPLE: session-status message ready? ;
|
||||
|
||||
: current-web-driver-session> ( -- session )
|
||||
|
@ -334,23 +335,28 @@ TUPLE: rect x y width height ;
|
|||
<any-port-local-inet4> utf8 <server>
|
||||
[ addr>> port>> ] [ dispose ] bi number>string ;
|
||||
|
||||
: <chrome-driver-process> ( capabilities -- process )
|
||||
drop
|
||||
"chromedriver --silent --port 4444" utf8 <process-stream> ;
|
||||
: <web-driver-process> ( host port command -- process )
|
||||
-rot '{ _ "--host" _ "--port" _ } utf8 <process-reader> ;
|
||||
|
||||
: <gecko-driver-process> ( host port -- process )
|
||||
'{ "geckodriver" "--host" _ "--port" _ } utf8 <process-reader> ;
|
||||
"geckodriver" <web-driver-process> ;
|
||||
|
||||
: <web-driver-session> ( -- )
|
||||
: <chrome-driver-process> ( host port -- process )
|
||||
"chromedriver" <web-driver-process> ;
|
||||
|
||||
: init-driver-session ( -- )
|
||||
"127.0.0.1" get-free-listen-port
|
||||
[ ":" prepend append "http://" prepend "/" append >url ]
|
||||
[ <gecko-driver-process> ] 2bi
|
||||
f f web-driver-session boa
|
||||
>current-web-driver-session ;
|
||||
|
||||
! [ ready?>> ] [ status 1 seconds sleep ] do until
|
||||
!
|
||||
! new-session [ "sessionId" of ] [ "capabilities" of ] bi
|
||||
!
|
||||
! current-web-driver-session> swap >>capabilities swap >>session-id
|
||||
! >current-web-driver-session ;
|
||||
: <web-driver-session> ( capabilities -- )
|
||||
init-driver-session
|
||||
|
||||
[ ready?>> ] [ 1 seconds sleep status ] do until
|
||||
|
||||
new-session [ "sessionId" of ] [ "capabilities" of ] bi
|
||||
|
||||
current-web-driver-session> swap >>capabilities swap >>session-id
|
||||
>current-web-driver-session ;
|
||||
|
|
Loading…
Reference in New Issue