WebDriver/src/WebDriver/WDElement.class.st

175 lines
3.3 KiB
Smalltalk

"
I represent a DOM element.
For the Responsibility part: Three sentences about my main responsibilities - what I do, what I know.
For the Collaborators Part: State my main collaborators and one line about how I interact with them.
Public API and Key Messages
- message one
- message two
- (for bonus points) how to create instances.
One simple example is simply gorgeous.
Internal Representation and Key Implementation Points.
Instance Variables
driver: <Object>
element: <Object>
Implementation Points
"
Class {
#name : #WDElement,
#superclass : #Object,
#instVars : [
'driver',
'element'
],
#category : #'WebDriver-Base'
}
{ #category : #accessing }
WDElement >> attribute: attr [
| result |
result := self driver
sendWithSession: { }
to:
'element/' , element , '/attribute/'
, attr
using: #GET.
^ result = 'true' ifTrue: [ true ] ifFalse: [ result ].
]
{ #category : #accessing }
WDElement >> attributes [
| script result |
script := 'var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value }; return items;'.
result := driver sendWithSession: { #script -> script . #args -> { 'element-6066-11e4-a52e-4f735466cecf' -> element } asDictionary }
to: 'element/' , element , '/execute/sync'
using: #POST.
^ result.
]
{ #category : #simulating }
WDElement >> clear [
self driver
sendWithSession: { }
to: 'element/' , element , '/clear'
using: #POST
]
{ #category : #simulating }
WDElement >> click [
self driver
sendWithSession: { }
to: 'element/' , element , '/click'
using: #POST
]
{ #category : #accessing }
WDElement >> computedLabel [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/computedlabel'
using: #GET
]
{ #category : #accessing }
WDElement >> computedRole [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/computedrole'
using: #GET
]
{ #category : #'private - utilities' }
WDElement >> driver [
^ driver
]
{ #category : #'private - utilities' }
WDElement >> driver: anObject [
driver := anObject
]
{ #category : #'private - utilities' }
WDElement >> element [
^ element
]
{ #category : #'private - utilities' }
WDElement >> element: anObject [
element := anObject
]
{ #category : #accessing }
WDElement >> isEnabled [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/enabled'
using: #GET
]
{ #category : #accessing }
WDElement >> isSelected [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/selected'
using: #GET
]
{ #category : #accessing }
WDElement >> name [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/name'
using: #GET
]
{ #category : #accessing }
WDElement >> property: attr [
^ self driver
sendWithSession: { }
to:
'element/' , element , '/property/'
, attr
using: #GET
]
{ #category : #accessing }
WDElement >> rect [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/rect'
using: #GET
]
{ #category : #accessing }
WDElement >> text [
^ self driver
sendWithSession: { }
to: 'element/' , element , '/text'
using: #GET
]
{ #category : #simulating }
WDElement >> value: text [
self driver
sendWithSession: { (#text -> text) }
to: 'element/' , element , '/value'
using: #POST
]