Refactoring progress
This commit is contained in:
parent
d014f5c76e
commit
f482637e2c
|
@ -0,0 +1,25 @@
|
|||
"
|
||||
A WDElementTest is a test class for testing the behavior of WDElement
|
||||
"
|
||||
Class {
|
||||
#name : #WDElementTest,
|
||||
#superclass : #TestCase,
|
||||
#instVars : [
|
||||
'driver'
|
||||
],
|
||||
#category : #'WebDriver-Tests-Base'
|
||||
}
|
||||
|
||||
{ #category : #running }
|
||||
WDElementTest >> setUp [
|
||||
super setUp.
|
||||
driver := WebDriver start: #Firefox.
|
||||
driver session.
|
||||
]
|
||||
|
||||
{ #category : #running }
|
||||
WDElementTest >> tearDown [
|
||||
driver deleteSession.
|
||||
driver finalize.
|
||||
super tearDown.
|
||||
]
|
|
@ -7,11 +7,11 @@ Class {
|
|||
#instVars : [
|
||||
'webdriver'
|
||||
],
|
||||
#category : #'WebDriver-Tests'
|
||||
#category : #'WebDriver-Tests-Base'
|
||||
}
|
||||
|
||||
{ #category : #running }
|
||||
WebDriverTest >> setUp [
|
||||
WebDriverTest >> setUp [
|
||||
super setUp.
|
||||
webdriver := WebDriver start: #Firefox.
|
||||
webdriver session.
|
||||
|
@ -20,39 +20,11 @@ WebDriverTest >> setUp [
|
|||
{ #category : #running }
|
||||
WebDriverTest >> tearDown [
|
||||
webdriver deleteSession.
|
||||
webdriver finalize.
|
||||
super tearDown.
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
WebDriverTest >> testFindElementInvalidCSSSelector [
|
||||
self
|
||||
should: [ webdriver url: 'https://ddg.co'; findElement: '' using: WDLocationStrategy cssSelector ]
|
||||
raise: WDInvalidSelector.
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
WebDriverTest >> testFindElementValid [
|
||||
| result |
|
||||
result := webdriver url: 'https://ddg.co'; findElement: '.logo_homepage' using: WDLocationStrategy cssSelector.
|
||||
self assert: (result isString).
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
WebDriverTest >> testFindElementsInvalidCSSSelector [
|
||||
self
|
||||
should: [ webdriver url: 'https://ddg.co'; findElements: '' using: WDLocationStrategy cssSelector ]
|
||||
raise: WDInvalidSelector.
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
WebDriverTest >> testFindElementsValid [
|
||||
| result |
|
||||
result := webdriver url: 'https://ddg.co';
|
||||
findElements: '.badge-link__bullet' using: WDLocationStrategy cssSelector.
|
||||
self assert: result size equals: 3.
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
WebDriverTest >> testGetTitle [
|
||||
self assert: (webdriver url: 'https://cern.ch'; title) equals: 'Home | CERN'
|
||||
self assert: (webdriver url: 'https://cern.ch'; title) equals: 'Home | CERN'.
|
||||
]
|
||||
|
|
|
@ -170,7 +170,8 @@ WebDriver >> send: dict to: url using: method [
|
|||
contentReader: [ :entity |
|
||||
result := (NeoJSONReader on: (entity contents) readStream) propertyNamesAsSymbols: true; next.
|
||||
result := self postprocessResult: result.
|
||||
(result keys contains: #error) ifTrue: [ WDException raise: result ].
|
||||
result isDictionary ifTrue:
|
||||
[ (result includesKey: #error) ifTrue: [ WDException raise: result ]. ]
|
||||
];
|
||||
execute.
|
||||
^result.
|
||||
|
|
|
@ -18,6 +18,7 @@ WebDriverGeckodriver class >> startWithOptions: options [
|
|||
subproc := OSSUnixSubprocess new
|
||||
command: 'geckodriver'.
|
||||
[ subproc run ] fork.
|
||||
(Delay forSeconds: 1) wait.
|
||||
^ self new
|
||||
browser: subproc
|
||||
server: '127.0.0.1'
|
||||
|
@ -40,5 +41,13 @@ WebDriverGeckodriver >> initialize [
|
|||
|
||||
{ #category : #'private - utilities' }
|
||||
WebDriverGeckodriver >> postprocessResult: result [
|
||||
^ result at: #value.
|
||||
|
||||
| actualResult |
|
||||
actualResult := result isDictionary
|
||||
ifTrue: [
|
||||
(result includesKey: #value)
|
||||
ifTrue: [ result at: #value ]
|
||||
ifFalse: [ result ] ]
|
||||
ifFalse: [ result ].
|
||||
^ actualResult
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue