| 1 | package Selenium::Client::Commands; | ||||||||||
| 2 | 2 | $Selenium::Client::Commands::VERSION = '2.01'; | |||||||||
| 3 | # ABSTRACT: Map commands from Selenium 3 to 4 | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Carp::Always; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | # Polyfill from Selenium 4's spec to JSONWire + Selenium 3 | ||||||||||
| 11 | my %using = ( | ||||||||||
| 12 | 0 | ▶ | 'class name' => sub { ( "css selector", ".$_[0]" ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 13 | 0 | ▶ | 'name' => sub { ( "css selector", "[name='$_[0]']" ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 14 | 0 | ▶ | 'id' => sub { ( "css selector", "#$_[0]" ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 15 | 2 | ); | |||||||||
| 16 | |||||||||||
| 17 | 0 | ▶ | sub _toughshit { | ||||||||
|
Subroutine
_toughshit: not called CC=1 SCAR=6.9
| |||||||||||
| 18 | 0 | my ( $session, $params, $cmd ) = @_; | |||||||||
| 19 | 0 | die "Sorry, Selenium 4 does not support $cmd! Try downgrading your browser, driver binary, Selenium JAR and so forth to something that understands JSONWire protocol, Selenium 3, or use playwright which supports all this functionality and more."; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub _emit { | ||||||||
|
Subroutine
_emit: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | 0 | my ( $session, $ret ) = @_; | |||||||||
| 24 | 0 | return $ret; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub _emit_null_ok { | ||||||||
|
Subroutine
_emit_null_ok: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | 0 | my ( $session, $ret ) = @_; | |||||||||
| 29 | 0 | return !defined $ret; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub _timeout { | ||||||||
|
Subroutine
_timeout: not called CC=1 SCAR=6.9
| |||||||||||
| 33 | 0 | my ( $session, $params ) = @_; | |||||||||
| 34 | 0 | return $session->SetTimeouts(%$params); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub _sess_uc { | ||||||||
|
Subroutine
_sess_uc: not called CC=2 SCAR=17.9
| |||||||||||
| 38 | 0 | my ( $session, $params, $cmd ) = @_; | |||||||||
| 39 | 0 | $cmd = ucfirst($cmd); | |||||||||
| 40 | 0 | ▶ | die "NO SESSION PROVIDED!" unless $session; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | return $session->$cmd(%$params); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | my %command_map = ( | ||||||||||
| 45 | 'status' => { | ||||||||||
| 46 | driver => 1, | ||||||||||
| 47 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | 0 | my ( $driver, $params ) = @_; | |||||||||
| 49 | 0 | return $driver->Status(); | |||||||||
| 50 | }, | ||||||||||
| 51 | 0 | ▶ | parse => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | 0 | my ( $driver, $ret ) = @_; | |||||||||
| 53 | 0 | return $ret; | |||||||||
| 54 | }, | ||||||||||
| 55 | }, | ||||||||||
| 56 | 'newSession' => { | ||||||||||
| 57 | driver => 1, | ||||||||||
| 58 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 59 | 0 | my ( $driver, $params ) = @_; | |||||||||
| 60 | 0 | foreach my $key ( keys(%$params) ) { | |||||||||
| 61 | |||||||||||
| 62 | #XXX may not be the smartest idea | ||||||||||
| 63 | 0 | ▶ | delete $params->{$key} unless $params->{$key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | my %in = %$params ? ( capabilities => { alwaysMatch => $params } ) : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | #XXX TODO the params we build here are worse than what is autobuilt by default. Ignore them totally. | ||||||||||
| 69 | 0 | my @ret = $driver->NewSession(); | |||||||||
| 70 | 0 | return [@ret]; | |||||||||
| 71 | }, | ||||||||||
| 72 | 0 | ▶ | parse => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 73 | 0 | my ( $driver, $ret ) = @_; | |||||||||
| 74 | 0 | my ( $capabilities, $session ) = @$ret; | |||||||||
| 75 | 0 | return { capabilities => $capabilities, session => $session }; | |||||||||
| 76 | }, | ||||||||||
| 77 | }, | ||||||||||
| 78 | 'setTimeout' => { | ||||||||||
| 79 | execute => \&_timeout, | ||||||||||
| 80 | parse => \&_emit, | ||||||||||
| 81 | }, | ||||||||||
| 82 | 'setAsyncScriptTimeout' => { | ||||||||||
| 83 | execute => \&_timeout, | ||||||||||
| 84 | parse => \&_emit, | ||||||||||
| 85 | }, | ||||||||||
| 86 | 'setImplicitWaitTimeout' => { | ||||||||||
| 87 | execute => \&_timeout, | ||||||||||
| 88 | parse => \&_emit, | ||||||||||
| 89 | }, | ||||||||||
| 90 | 'getTimeouts' => { | ||||||||||
| 91 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 92 | 0 | my ( $session, $params ) = @_; | |||||||||
| 93 | 0 | return $session->GetTimeouts(); | |||||||||
| 94 | }, | ||||||||||
| 95 | parse => \&_emit, | ||||||||||
| 96 | }, | ||||||||||
| 97 | |||||||||||
| 98 | #TODO murder the driver object too | ||||||||||
| 99 | 'quit' => { | ||||||||||
| 100 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 101 | 0 | my ( $session, $params ) = @_; | |||||||||
| 102 | 0 | return $session->DeleteSession( sessionid => $session->{sessionid} ); | |||||||||
| 103 | }, | ||||||||||
| 104 | parse => \&_emit_null_ok, | ||||||||||
| 105 | }, | ||||||||||
| 106 | 'getCurrentWindowHandle' => { | ||||||||||
| 107 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 108 | 0 | my ( $session, $params ) = @_; | |||||||||
| 109 | 0 | return $session->GetWindowHandle(%$params); | |||||||||
| 110 | }, | ||||||||||
| 111 | parse => \&_emit, | ||||||||||
| 112 | }, | ||||||||||
| 113 | 'getWindowHandles' => { | ||||||||||
| 114 | execute => \&_sess_uc, | ||||||||||
| 115 | parse => \&_emit, | ||||||||||
| 116 | }, | ||||||||||
| 117 | |||||||||||
| 118 | #TODO May require output filtering | ||||||||||
| 119 | 'getWindowSize' => { | ||||||||||
| 120 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 121 | 0 | my ( $session, $params ) = @_; | |||||||||
| 122 | 0 | return $session->GetWindowRect(%$params); | |||||||||
| 123 | }, | ||||||||||
| 124 | parse => \&_emit, | ||||||||||
| 125 | }, | ||||||||||
| 126 | 'getWindowPosition' => { | ||||||||||
| 127 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 128 | 0 | my ( $session, $params ) = @_; | |||||||||
| 129 | 0 | return $session->GetWindowRect(%$params); | |||||||||
| 130 | }, | ||||||||||
| 131 | parse => \&_emit, | ||||||||||
| 132 | }, | ||||||||||
| 133 | 'getWindowRect' => { | ||||||||||
| 134 | execute => \&_sess_uc, | ||||||||||
| 135 | parse => \&_emit, | ||||||||||
| 136 | }, | ||||||||||
| 137 | 'setWindowRect' => { | ||||||||||
| 138 | execute => \&_sess_uc, | ||||||||||
| 139 | parse => \&_emit, | ||||||||||
| 140 | }, | ||||||||||
| 141 | 'maximizeWindow' => { | ||||||||||
| 142 | execute => \&_sess_uc, | ||||||||||
| 143 | parse => \&_emit, | ||||||||||
| 144 | }, | ||||||||||
| 145 | 'minimizeWindow' => { | ||||||||||
| 146 | execute => \&_sess_uc, | ||||||||||
| 147 | parse => \&_emit, | ||||||||||
| 148 | }, | ||||||||||
| 149 | 'fullscreenWindow' => { | ||||||||||
| 150 | execute => \&_sess_uc, | ||||||||||
| 151 | parse => \&_emit, | ||||||||||
| 152 | }, | ||||||||||
| 153 | 'setWindowSize' => { | ||||||||||
| 154 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 155 | 0 | my ( $session, $params ) = @_; | |||||||||
| 156 | 0 | return $session->SetWindowRect(%$params); | |||||||||
| 157 | }, | ||||||||||
| 158 | parse => \&_emit_null_ok, | ||||||||||
| 159 | }, | ||||||||||
| 160 | 'setWindowPosition' => { | ||||||||||
| 161 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 162 | 0 | my ( $session, $params ) = @_; | |||||||||
| 163 | 0 | return $session->SetWindowRect(%$params); | |||||||||
| 164 | }, | ||||||||||
| 165 | parse => \&_emit_null_ok, | ||||||||||
| 166 | }, | ||||||||||
| 167 | 'getCurrentUrl' => { | ||||||||||
| 168 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 169 | 0 | my ( $session, $params ) = @_; | |||||||||
| 170 | 0 | return $session->GetCurrentURL(%$params); | |||||||||
| 171 | }, | ||||||||||
| 172 | parse => \&_emit, | ||||||||||
| 173 | }, | ||||||||||
| 174 | 'get' => { | ||||||||||
| 175 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 176 | 0 | my ( $session, $params ) = @_; | |||||||||
| 177 | 0 | return $session->NavigateTo(%$params); | |||||||||
| 178 | }, | ||||||||||
| 179 | parse => \&_emit_null_ok, | ||||||||||
| 180 | }, | ||||||||||
| 181 | 'goForward' => { | ||||||||||
| 182 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 183 | 0 | my ( $session, $params ) = @_; | |||||||||
| 184 | 0 | return $session->Forward(%$params); | |||||||||
| 185 | }, | ||||||||||
| 186 | parse => \&_emit_null_ok, | ||||||||||
| 187 | }, | ||||||||||
| 188 | 'goBack' => { | ||||||||||
| 189 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 190 | 0 | my ( $session, $params ) = @_; | |||||||||
| 191 | 0 | return $session->Back(%$params); | |||||||||
| 192 | }, | ||||||||||
| 193 | parse => \&_emit_null_ok, | ||||||||||
| 194 | }, | ||||||||||
| 195 | 'refresh' => { | ||||||||||
| 196 | execute => \&_sess_uc, | ||||||||||
| 197 | parse => \&_emit, | ||||||||||
| 198 | }, | ||||||||||
| 199 | 'executeScript' => { | ||||||||||
| 200 | execute => \&_sess_uc, | ||||||||||
| 201 | parse => \&_emit, | ||||||||||
| 202 | }, | ||||||||||
| 203 | 'executeAsyncScript' => { | ||||||||||
| 204 | execute => \&_sess_uc, | ||||||||||
| 205 | parse => \&_emit, | ||||||||||
| 206 | }, | ||||||||||
| 207 | 'screenshot' => { | ||||||||||
| 208 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 209 | 0 | my ( $session, $params ) = @_; | |||||||||
| 210 | 0 | $session->TakeScreenshot(%$params); | |||||||||
| 211 | }, | ||||||||||
| 212 | parse => \&_emit, | ||||||||||
| 213 | }, | ||||||||||
| 214 | 'elementScreenshot' => { | ||||||||||
| 215 | session => 1, | ||||||||||
| 216 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 217 | 0 | my ( $session, $params ) = @_; | |||||||||
| 218 | 0 | $session->TakeElementScreenshot(%$params); | |||||||||
| 219 | }, | ||||||||||
| 220 | parse => \&_emit, | ||||||||||
| 221 | }, | ||||||||||
| 222 | 'availableEngines' => { | ||||||||||
| 223 | execute => \&_toughshit, | ||||||||||
| 224 | }, | ||||||||||
| 225 | 'switchToFrame' => { | ||||||||||
| 226 | execute => \&_sess_uc, | ||||||||||
| 227 | parse => \&_emit_null_ok, | ||||||||||
| 228 | }, | ||||||||||
| 229 | 'switchToParentFrame' => { | ||||||||||
| 230 | execute => \&_sess_uc, | ||||||||||
| 231 | parse => \&_emit_null_ok, | ||||||||||
| 232 | }, | ||||||||||
| 233 | 'switchToWindow' => { | ||||||||||
| 234 | execute => \&_sess_uc, | ||||||||||
| 235 | parse => \&_emit_null_ok, | ||||||||||
| 236 | }, | ||||||||||
| 237 | 'getAllCookies' => { | ||||||||||
| 238 | execute => \&_sess_uc, | ||||||||||
| 239 | parse => \&_emit, | ||||||||||
| 240 | }, | ||||||||||
| 241 | 'getCookieNamed' => { | ||||||||||
| 242 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 243 | 0 | my ( $session, $params ) = @_; | |||||||||
| 244 | 0 | return $session->GetNamedCookie(%$params); | |||||||||
| 245 | }, | ||||||||||
| 246 | parse => \&_emit, | ||||||||||
| 247 | }, | ||||||||||
| 248 | 'addCookie' => { | ||||||||||
| 249 | execute => \&_sess_uc, | ||||||||||
| 250 | parse => \&_emit_null_ok, | ||||||||||
| 251 | }, | ||||||||||
| 252 | 'deleteAllCookies' => { | ||||||||||
| 253 | execute => \&_sess_uc, | ||||||||||
| 254 | parse => \&_emit_null_ok, | ||||||||||
| 255 | }, | ||||||||||
| 256 | 'deleteCookieNamed' => { | ||||||||||
| 257 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 258 | 0 | my ( $session, $params ) = @_; | |||||||||
| 259 | 0 | return $session->DeleteCookie(%$params); | |||||||||
| 260 | }, | ||||||||||
| 261 | parse => \&_emit, | ||||||||||
| 262 | }, | ||||||||||
| 263 | 'getPageSource' => { | ||||||||||
| 264 | execute => \&_sess_uc, | ||||||||||
| 265 | parse => \&_emit, | ||||||||||
| 266 | }, | ||||||||||
| 267 | 'getTitle' => { | ||||||||||
| 268 | execute => \&_sess_uc, | ||||||||||
| 269 | parse => \&_emit, | ||||||||||
| 270 | }, | ||||||||||
| 271 | 'findElement' => { | ||||||||||
| 272 | scd => 1, | ||||||||||
| 273 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 274 | 0 | my ( $driver, $params ) = @_; | |||||||||
| 275 | |||||||||||
| 276 | # Fix old selector types | ||||||||||
| 277 | 0 | ▶ | ( $params->{using}, $params->{value} ) = $using{ $params->{using} }->( $params->{value} ) if exists $using{ $params->{using} }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 278 | 0 | my $element = $driver->session->FindElement(%$params); | |||||||||
| 279 | 0 | return $element; | |||||||||
| 280 | }, | ||||||||||
| 281 | parse => \&_emit, | ||||||||||
| 282 | }, | ||||||||||
| 283 | 'findElements' => { | ||||||||||
| 284 | scd => 1, | ||||||||||
| 285 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 286 | 0 | my ( $driver, $params ) = @_; | |||||||||
| 287 | |||||||||||
| 288 | # Fix old selector types | ||||||||||
| 289 | 0 | ▶ | ( $params->{using}, $params->{value} ) = $using{ $params->{using} }->( $params->{value} ) if exists $using{ $params->{using} }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 290 | 0 | my @elements = $driver->session->FindElements(%$params); | |||||||||
| 291 | 0 | ▶ | return wantarray ? @elements : \@elements; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 292 | }, | ||||||||||
| 293 | parse => \&_emit, | ||||||||||
| 294 | }, | ||||||||||
| 295 | 'getActiveElement' => { | ||||||||||
| 296 | execute => \&_sess_uc, | ||||||||||
| 297 | parse => \&_emit, | ||||||||||
| 298 | }, | ||||||||||
| 299 | 'describeElement' => { | ||||||||||
| 300 | execute => \&_toughshit, | ||||||||||
| 301 | }, | ||||||||||
| 302 | 'findChildElement' => { | ||||||||||
| 303 | execute => \&_toughshit, | ||||||||||
| 304 | }, | ||||||||||
| 305 | 'findChildElements' => { | ||||||||||
| 306 | execute => \&_toughshit, | ||||||||||
| 307 | }, | ||||||||||
| 308 | 'clickElement' => { | ||||||||||
| 309 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 310 | 0 | my ( $element, $params ) = @_; | |||||||||
| 311 | 0 | $element->ElementClick(%$params); | |||||||||
| 312 | }, | ||||||||||
| 313 | parse => \&_emit_null_ok, | ||||||||||
| 314 | }, | ||||||||||
| 315 | |||||||||||
| 316 | # TODO polyfill as send enter? | ||||||||||
| 317 | 'submitElement' => { | ||||||||||
| 318 | execute => \&_toughshit, | ||||||||||
| 319 | }, | ||||||||||
| 320 | 'sendKeysToElement' => { | ||||||||||
| 321 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 322 | 0 | my ( $element, $params ) = @_; | |||||||||
| 323 | 0 | $element->ElementSendKeys(%$params); | |||||||||
| 324 | }, | ||||||||||
| 325 | parse => \&_emit, | ||||||||||
| 326 | }, | ||||||||||
| 327 | 'sendKeysToActiveElement' => { | ||||||||||
| 328 | execute => \&_toughshit, | ||||||||||
| 329 | }, | ||||||||||
| 330 | 'sendModifier' => { | ||||||||||
| 331 | execute => \&_toughshit, | ||||||||||
| 332 | }, | ||||||||||
| 333 | 'isElementSelected' => { | ||||||||||
| 334 | execute => \&_sess_uc, | ||||||||||
| 335 | parse => \&_emit, | ||||||||||
| 336 | }, | ||||||||||
| 337 | |||||||||||
| 338 | # TODO polyfill | ||||||||||
| 339 | 'setElementSelected' => { | ||||||||||
| 340 | execute => \&_toughshit, | ||||||||||
| 341 | }, | ||||||||||
| 342 | 'toggleElement' => { | ||||||||||
| 343 | execute => \&_toughshit, | ||||||||||
| 344 | }, | ||||||||||
| 345 | 'isElementEnabled' => { | ||||||||||
| 346 | element => 1, | ||||||||||
| 347 | execute => \&_sess_uc, | ||||||||||
| 348 | parse => \&_emit, | ||||||||||
| 349 | }, | ||||||||||
| 350 | 'getElementLocation' => { | ||||||||||
| 351 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 352 | 0 | my ( $element, $params ) = @_; | |||||||||
| 353 | 0 | return $element->GetElementRect(%$params); | |||||||||
| 354 | }, | ||||||||||
| 355 | parse => \&_emit, | ||||||||||
| 356 | }, | ||||||||||
| 357 | 'getElementRect' => { | ||||||||||
| 358 | execute => \&_sess_uc, | ||||||||||
| 359 | parse => \&_emit, | ||||||||||
| 360 | }, | ||||||||||
| 361 | 'getElementLocationInView' => { | ||||||||||
| 362 | execute => \&_toughshit, | ||||||||||
| 363 | }, | ||||||||||
| 364 | 'getElementTagName' => { | ||||||||||
| 365 | execute => \&_sess_uc, | ||||||||||
| 366 | parse => \&_emit, | ||||||||||
| 367 | }, | ||||||||||
| 368 | 'clearElement' => { | ||||||||||
| 369 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 370 | 0 | my ( $element, $params ) = @_; | |||||||||
| 371 | 0 | return $element->ElementClear(%$params); | |||||||||
| 372 | }, | ||||||||||
| 373 | parse => \&_emit, | ||||||||||
| 374 | }, | ||||||||||
| 375 | 'getElementAttribute' => { | ||||||||||
| 376 | execute => \&_sess_uc, | ||||||||||
| 377 | parse => \&_emit, | ||||||||||
| 378 | }, | ||||||||||
| 379 | 'getElementProperty' => { | ||||||||||
| 380 | execute => \&_sess_uc, | ||||||||||
| 381 | parse => \&_emit, | ||||||||||
| 382 | }, | ||||||||||
| 383 | |||||||||||
| 384 | # TODO polyfills | ||||||||||
| 385 | 'elementEquals' => { | ||||||||||
| 386 | execute => \&_toughshit, | ||||||||||
| 387 | }, | ||||||||||
| 388 | 'isElementDisplayed' => { | ||||||||||
| 389 | execute => \&_toughshit, | ||||||||||
| 390 | }, | ||||||||||
| 391 | 'close' => { | ||||||||||
| 392 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 393 | 0 | my ( $session, $params ) = @_; | |||||||||
| 394 | 0 | $session->CloseWindow(%$params); | |||||||||
| 395 | }, | ||||||||||
| 396 | parse => \&_emit_null_ok, | ||||||||||
| 397 | }, | ||||||||||
| 398 | 'getElementSize' => { | ||||||||||
| 399 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 400 | 0 | my ( $element, $params ) = @_; | |||||||||
| 401 | 0 | return $element->GetElementRect(%$params); | |||||||||
| 402 | }, | ||||||||||
| 403 | parse => \&_emit, | ||||||||||
| 404 | }, | ||||||||||
| 405 | 'getElementText' => { | ||||||||||
| 406 | execute => \&_sess_uc, | ||||||||||
| 407 | parse => \&_emit, | ||||||||||
| 408 | }, | ||||||||||
| 409 | 'getElementValueOfCssProperty' => { | ||||||||||
| 410 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 411 | 0 | my ( $element, $params ) = @_; | |||||||||
| 412 | 0 | return $element->GetElementCSSValue(%$params); | |||||||||
| 413 | }, | ||||||||||
| 414 | parse => \&_emit, | ||||||||||
| 415 | }, | ||||||||||
| 416 | 'mouseMoveToLocation' => { | ||||||||||
| 417 | execute => \&_toughshit, | ||||||||||
| 418 | }, | ||||||||||
| 419 | 'getAlertText' => { | ||||||||||
| 420 | execute => \&_sess_uc, | ||||||||||
| 421 | parse => \&_emit, | ||||||||||
| 422 | }, | ||||||||||
| 423 | 'sendKeysToPrompt' => { | ||||||||||
| 424 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 425 | 0 | my ( $session, $params ) = @_; | |||||||||
| 426 | 0 | $session->SendAlertText(%$params); | |||||||||
| 427 | }, | ||||||||||
| 428 | parse => \&_emit_null_ok, | ||||||||||
| 429 | }, | ||||||||||
| 430 | 'acceptAlert' => { | ||||||||||
| 431 | execute => \&_sess_uc, | ||||||||||
| 432 | parse => \&_emit_null_ok, | ||||||||||
| 433 | }, | ||||||||||
| 434 | 'dismissAlert' => { | ||||||||||
| 435 | execute => \&_sess_uc, | ||||||||||
| 436 | parse => \&_emit_null_ok, | ||||||||||
| 437 | }, | ||||||||||
| 438 | 'click' => { | ||||||||||
| 439 | execute => \&_toughshit, | ||||||||||
| 440 | }, | ||||||||||
| 441 | 'doubleClick' => { | ||||||||||
| 442 | execute => \&_toughshit, | ||||||||||
| 443 | }, | ||||||||||
| 444 | 'buttonDown' => { | ||||||||||
| 445 | execute => \&_toughshit, | ||||||||||
| 446 | }, | ||||||||||
| 447 | 'buttonUp' => { | ||||||||||
| 448 | execute => \&_toughshit, | ||||||||||
| 449 | }, | ||||||||||
| 450 | 'uploadFile' => { | ||||||||||
| 451 | execute => \&_toughshit, | ||||||||||
| 452 | }, | ||||||||||
| 453 | 'getLocalStorageItem' => { | ||||||||||
| 454 | execute => \&_toughshit, | ||||||||||
| 455 | }, | ||||||||||
| 456 | 'deleteLocalStorageItem' => { | ||||||||||
| 457 | execute => \&_toughshit, | ||||||||||
| 458 | }, | ||||||||||
| 459 | 'cacheStatus' => { | ||||||||||
| 460 | execute => \&_toughshit, | ||||||||||
| 461 | }, | ||||||||||
| 462 | 'setGeolocation' => { | ||||||||||
| 463 | execute => \&_toughshit, | ||||||||||
| 464 | }, | ||||||||||
| 465 | 'getGeolocation' => { | ||||||||||
| 466 | execute => \&_toughshit, | ||||||||||
| 467 | }, | ||||||||||
| 468 | 'getLog' => { | ||||||||||
| 469 | execute => \&_toughshit, | ||||||||||
| 470 | }, | ||||||||||
| 471 | 'getLogTypes' => { | ||||||||||
| 472 | execute => \&_toughshit, | ||||||||||
| 473 | }, | ||||||||||
| 474 | 'setOrientation' => { | ||||||||||
| 475 | execute => \&_toughshit, | ||||||||||
| 476 | }, | ||||||||||
| 477 | 'getOrientation' => { | ||||||||||
| 478 | execute => \&_toughshit, | ||||||||||
| 479 | }, | ||||||||||
| 480 | |||||||||||
| 481 | # firefox extension | ||||||||||
| 482 | 'setContext' => { | ||||||||||
| 483 | execute => \&_toughshit, | ||||||||||
| 484 | }, | ||||||||||
| 485 | 'getContext' => { | ||||||||||
| 486 | execute => \&_toughshit, | ||||||||||
| 487 | }, | ||||||||||
| 488 | |||||||||||
| 489 | # geckodriver workarounds | ||||||||||
| 490 | 'executeScriptGecko' => { | ||||||||||
| 491 | execute => \&_toughshit, | ||||||||||
| 492 | }, | ||||||||||
| 493 | 'executeAsyncScriptGecko' => { | ||||||||||
| 494 | execute => \&_toughshit, | ||||||||||
| 495 | }, | ||||||||||
| 496 | generalAction => { | ||||||||||
| 497 | session => 1, | ||||||||||
| 498 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 499 | 0 | my ( $session, $params ) = @_; | |||||||||
| 500 | 0 | return $session->PerformActions(%$params); | |||||||||
| 501 | }, | ||||||||||
| 502 | parse => \&_emit_null_ok, | ||||||||||
| 503 | }, | ||||||||||
| 504 | releaseGeneralAction => { | ||||||||||
| 505 | session => 1, | ||||||||||
| 506 | 0 | ▶ | execute => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 507 | 0 | my ( $session, $params ) = @_; | |||||||||
| 508 | 0 | return $session->ReleaseActions(%$params); | |||||||||
| 509 | }, | ||||||||||
| 510 | 2 | parse => \&_emit_null_ok, | |||||||||
| 511 | }, | ||||||||||
| 512 | ); | ||||||||||
| 513 | |||||||||||
| 514 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 515 | 0 | my $class = shift; | |||||||||
| 516 | 0 | return bless( {}, $class ); | |||||||||
| 517 | } | ||||||||||
| 518 | |||||||||||
| 519 | # Act like S::R::C | ||||||||||
| 520 | 0 | ▶ | sub parse_response { | ||||||||
|
Subroutine
parse_response: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 521 | 0 | my ( $self, $driver, $command, $response ) = @_; | |||||||||
| 522 | 0 | return $command_map{$command}{parse}->( $driver, $response ); | |||||||||
| 523 | } | ||||||||||
| 524 | |||||||||||
| 525 | # Act like S::R::RR | ||||||||||
| 526 | 0 | ▶ | sub request { | ||||||||
|
Subroutine
request: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 527 | 0 | my ( $self, $driver, $command, $args ) = @_; | |||||||||
| 528 | 0 | ▶ | die "No such command $command" unless ref $command_map{$command} eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 529 | 0 | return $command_map{$command}{execute}->( $driver, $args, $command ); | |||||||||
| 530 | } | ||||||||||
| 531 | |||||||||||
| 532 | 0 | ▶ | sub needs_driver { | ||||||||
|
Subroutine
needs_driver: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 533 | 0 | my ( $self, $command ) = @_; | |||||||||
| 534 | 0 | return $command_map{$command}{driver}; | |||||||||
| 535 | } | ||||||||||
| 536 | |||||||||||
| 537 | 0 | ▶ | sub needs_scd { | ||||||||
|
Subroutine
needs_scd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 538 | 0 | my ( $self, $command ) = @_; | |||||||||
| 539 | 0 | return $command_map{$command}{scd}; | |||||||||
| 540 | } | ||||||||||
| 541 | |||||||||||
| 542 | 2 | 1; | |||||||||
| 543 | |||||||||||
| 544 | __END__ | ||||||||||