diff --git a/src/WebDriver-Tests/WebDriverTest.class.st b/src/WebDriver-Tests/WebDriverTest.class.st index a178f5d..48d9ffe 100644 --- a/src/WebDriver-Tests/WebDriverTest.class.st +++ b/src/WebDriver-Tests/WebDriverTest.class.st @@ -13,7 +13,7 @@ Class { { #category : #running } WebDriverTest >> setUp [ super setUp. - webdriver := WebDriver geckodriver. + webdriver := WebDriver start: #Firefox. webdriver session. ] diff --git a/src/WebDriver/WebDriver.class.st b/src/WebDriver/WebDriver.class.st index ccabb77..2d850fd 100644 --- a/src/WebDriver/WebDriver.class.st +++ b/src/WebDriver/WebDriver.class.st @@ -42,16 +42,33 @@ Class { #category : #WebDriver } +{ #category : #testing } +WebDriver class >> matchesBrowserType: browserType [ + ^ self subclassResponsibility. +] + +{ #category : #accessing } +WebDriver class >> start: browserType [ + | emptyOpts | + emptyOpts := Dictionary new. + ^ self start: browserType with: emptyOpts. +] + { #category : #'instance creation' } -WebDriver class >> geckodriver [ - | subproc | - subproc := OSSUnixSubprocess new - command: 'geckodriver'. - [ subproc run ] fork. - ^ WebDriverGeckodriver new - browser: subproc - server: '127.0.0.1' - port: 4444. +WebDriver class >> start: browserType with: options [ + "comment stating purpose of class-side method" + "scope: class-variables & class-instance-variables" + + | matchingClass | + matchingClass := self subclasses + detect: [ :operationClass | operationClass matchesBrowserType: browserType ] + ifNone: [ self ]. + ^ matchingClass startWithOptions: options. +] + +{ #category : #'instance creation' } +WebDriver class >> startWithOptions: options [ + ^ self subclassResponsibility. ] { #category : #accessing } diff --git a/src/WebDriver/WebDriverGeckodriver.class.st b/src/WebDriver/WebDriverGeckodriver.class.st index 3cc04d5..6f0f8a4 100644 --- a/src/WebDriver/WebDriverGeckodriver.class.st +++ b/src/WebDriver/WebDriverGeckodriver.class.st @@ -7,6 +7,23 @@ Class { #category : #WebDriver } +{ #category : #testing } +WebDriverGeckodriver class >> matchesBrowserType: browserType [ + ^ browserType = #Firefox +] + +{ #category : #'instance creation' } +WebDriverGeckodriver class >> startWithOptions: options [ + | subproc | + subproc := OSSUnixSubprocess new + command: 'geckodriver'. + [ subproc run ] fork. + ^ self new + browser: subproc + server: '127.0.0.1' + port: 4444. +] + { #category : #'private - utilities' } WebDriverGeckodriver >> constructCapabilities: caps [