54 lines
1.3 KiB
Smalltalk
54 lines
1.3 KiB
Smalltalk
"
|
|
I implement the specifics and quirks to remote control a Firefox instance using Geckodriver.
|
|
"
|
|
Class {
|
|
#name : #WebDriverGeckodriver,
|
|
#superclass : #WebDriver,
|
|
#category : #'WebDriver-Base'
|
|
}
|
|
|
|
{ #category : #testing }
|
|
WebDriverGeckodriver class >> matchesBrowserType: browserType [
|
|
^ browserType = #Firefox
|
|
]
|
|
|
|
{ #category : #'instance creation' }
|
|
WebDriverGeckodriver class >> startWithOptions: options [
|
|
| subproc |
|
|
subproc := OSSUnixSubprocess new
|
|
command: 'geckodriver'.
|
|
[ subproc run ] fork.
|
|
(Delay forSeconds: 0.1) wait.
|
|
^ self new
|
|
browser: subproc
|
|
server: '127.0.0.1'
|
|
port: 4444.
|
|
]
|
|
|
|
{ #category : #'private - utilities' }
|
|
WebDriverGeckodriver >> constructCapabilities: caps [
|
|
|
|
^ { #desiredCapabilities
|
|
->
|
|
({ #moz:firefoxOptions -> ({ #prefs -> caps } asDictionary) }
|
|
asDictionary) } asDictionary.
|
|
]
|
|
|
|
{ #category : #initialization }
|
|
WebDriverGeckodriver >> initialize [
|
|
prefs := Dictionary new.
|
|
]
|
|
|
|
{ #category : #'private - utilities' }
|
|
WebDriverGeckodriver >> postprocessResult: result [
|
|
|
|
| actualResult |
|
|
actualResult := result isDictionary
|
|
ifTrue: [
|
|
(result includesKey: #value)
|
|
ifTrue: [ result at: #value ]
|
|
ifFalse: [ result ] ]
|
|
ifFalse: [ result ].
|
|
^ actualResult
|
|
]
|