Working basic version

This commit is contained in:
Daniel Ziltener 2022-04-26 00:46:29 +02:00
parent 0bebbc1e6b
commit e6d9203ea1
3 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,10 @@
Class {
#name : #WDKeys,
#superclass : #Object,
#category : #WebDriver
}
{ #category : #'accessing - token' }
WDKeys class >> return [
^ Character codePoint: 16rE006
]

View File

@ -0,0 +1,30 @@
Class {
#name : #WDLocationStrategy,
#superclass : #Object,
#category : #WebDriver
}
{ #category : #'as yet unclassified' }
WDLocationStrategy class >> cssSelector [
^'css selector'.
]
{ #category : #'as yet unclassified' }
WDLocationStrategy class >> linkText [
^'link text'.
]
{ #category : #'as yet unclassified' }
WDLocationStrategy class >> partialLinkText [
^'partial link text'.
]
{ #category : #accessing }
WDLocationStrategy class >> tagName [
^'tag name'.
]
{ #category : #'as yet unclassified' }
WDLocationStrategy class >> xPath [
^'xpath'.
]

View File

@ -11,8 +11,92 @@ Class {
#category : #WebDriver
}
{ #category : #positioning }
WebDriver >> back [
self send: { } to: 'session/',sessionId,'/back' using: #POST.
]
{ #category : #'as yet unclassified' }
WebDriver >> deleteSession [
"Deletes the session."
self send: {} to: 'session/',sessionId using: #DELETE.
]
{ #category : #'as yet unclassified' }
WebDriver >> findElement: elemSelector using: locStrategy [
^(self send: { #using -> locStrategy. #value -> elemSelector. } to: 'session/',sessionId,'/element' using: #POST) at: #value values first.
]
{ #category : #'as yet unclassified' }
WebDriver >> findElements: elemSelector using: locStrategy [
^(self send: { #using -> locStrategy. #value -> elemSelector. } to: 'session/',sessionId,'/elements' using: #POST) at: #value values.
]
{ #category : #positioning }
WebDriver >> forward [
self send: { } to: 'session/',sessionId,'/forward' using: #POST.
]
{ #category : #initialization }
WebDriver >> initialize: srv port: portnum [
server := srv.
port := portnum.
]
{ #category : #positioning }
WebDriver >> refresh [
self send: { } to: 'session/',sessionId,'/refresh' using: #POST.
]
{ #category : #'as yet unclassified' }
WebDriver >> send: dict to: url using: method [
|result|
result := nil.
ZnClient new
host: server;
port: port;
path: url;
contents: (NeoJSONWriter toString: dict asDictionary);
contentType: ZnMimeType applicationJson;
method: method;
contentReader: [ :entity |
result := (NeoJSONReader on: (entity contents) readStream) propertyNamesAsSymbols: true; next.
];
execute.
^result.
]
{ #category : #initialization }
WebDriver >> server: srv port: portnum [
server := srv.
port := portnum.
]
{ #category : #accessing }
WebDriver >> session [
"Initializes a new WebDriver session."
sessionId := (self send: {} to: 'session' using: #POST) at: #value at: #sessionId.
^sessionId.
]
{ #category : #accessing }
WebDriver >> status [
^ (self send: { } to: 'status' using: #GET) at: #value.
]
{ #category : #positioning }
WebDriver >> title [
^ (self send: { } to: 'session/',sessionId,'/title' using: #GET) at: #value.
]
{ #category : #'as yet unclassified' }
WebDriver >> type: text into: element [
self send: { #text -> text } to: 'session/',sessionId,'/element/',element,'/value' using: #POST.
]
{ #category : #accessing }
WebDriver >> url: url [
"Navigates the browser to the given URL."
self send: { #url -> url } to: 'session/',sessionId,'/url' using: #POST.
]