(command.CommandList
  children: [
    (C {(Id.KW_Set set)} {(-o)} {(pipefail)})
    (C {(shopt)} {(-s)} {(extglob)})
    (command.ShFunction
      name: main
      body: 
        (command.BraceGroup
          children: [
            (C {(Id.Lit_Other ':')} 
              {
                (DQ 
                  (braced_var_sub
                    token: (Token id:Id.VSub_Name val:WEBDRIVER_URL span_id:104)
                    suffix_op: 
                      (suffix_op.Unary
                        op_id: Id.VTest_ColonEquals
                        arg_word: 
                          {('http:') (Id.Lit_Slash /) (Id.Lit_Slash /) ('127.0.0.1:4444') 
                            (Id.Lit_Slash /) (wd) (Id.Lit_Slash /) (hub)
                          }
                      )
                  )
                )
              }
            )
            (command.Sentence
              child: 
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:cmd)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$1')}
                      spids: [119]
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:121)
            )
            (C {(shift)})
            (command.Case
              to_match: {($ Id.VSub_DollarName '$cmd')}
              arms: [
                (case_arm
                  pat_list: [{(new-session)}]
                  action: [(C {(wd-new-session)})]
                  spids: [133 134 139 -1]
                )
                (case_arm
                  pat_list: [{(delete-session)}]
                  action: [(C {(wd-delete-session)})]
                  spids: [142 143 148 -1]
                )
                (case_arm
                  pat_list: [{(go)}]
                  action: [(C {(wd-go)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [152 153 162 -1]
                )
                (case_arm
                  pat_list: [{(back)}]
                  action: [(C {(wd-post-session)} {(/back)})]
                  spids: [165 166 173 -1]
                )
                (case_arm
                  pat_list: [{(forward)}]
                  action: [(C {(wd-post-session)} {(/forward)})]
                  spids: [176 177 184 -1]
                )
                (case_arm
                  pat_list: [{(refresh)}]
                  action: [(C {(wd-post-session)} {(/refresh)})]
                  spids: [187 188 195 -1]
                )
                (case_arm
                  pat_list: [{(get-current-url)}]
                  action: [(C {(wd-get-current-url)})]
                  spids: [199 200 205 -1]
                )
                (case_arm
                  pat_list: [{(get-title)}]
                  action: [(C {(wd-get-title)})]
                  spids: [208 209 214 -1]
                )
                (case_arm
                  pat_list: [{(get-page-source)} {(page-source)}]
                  action: [(C {(wd-get-page-source)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [217 222 231 -1]
                )
                (case_arm
                  pat_list: [{(get-window-handle)}]
                  action: [(C {(wd-get-window-handle)})]
                  spids: [235 236 241 -1]
                )
                (case_arm
                  pat_list: [{(get-window-handles)}]
                  action: [(C {(wd-get-window-handles)})]
                  spids: [244 245 250 -1]
                )
                (case_arm
                  pat_list: [{(switch-to-window)}]
                  action: [(C {(wd-switch-to-window)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [254 255 264 -1]
                )
                (case_arm
                  pat_list: [{(switch-to-frame)}]
                  action: [(C {(wd-switch-to-frame)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [267 268 277 -1]
                )
                (case_arm
                  pat_list: [{(switch-to-parent-frame)}]
                  action: [(C {(wd-post-session)} {(/frame/parent)})]
                  spids: [280 281 288 -1]
                )
                (case_arm
                  pat_list: [{(get-window-size)}]
                  action: [(C {(wd-get-window-size)})]
                  spids: [292 293 298 -1]
                )
                (case_arm
                  pat_list: [{(set-window-size)}]
                  action: [(C {(wd-set-window-size)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [301 302 311 -1]
                )
                (case_arm
                  pat_list: [{(maximize)}]
                  action: [(C {(wd-maximize)})]
                  spids: [314 315 320 -1]
                )
                (case_arm
                  pat_list: [{(find-element)} {(find)}]
                  action: [(C {(wd-find-element)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [324 329 338 -1]
                )
                (case_arm
                  pat_list: [{(find-elements)} {(find-all)}]
                  action: [(C {(wd-find-elements)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [341 346 355 -1]
                )
                (case_arm
                  pat_list: [{(find-element-in)} {(find-in)} {(find-element-from-element)}]
                  action: [(C {(wd-find-element-from-element)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [358 367 376 -1]
                )
                (case_arm
                  pat_list: [{(find-elements-in)} {(find-all-in)} {(find-elements-from-element)}]
                  action: [(C {(wd-find-elements-from-element)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [379 388 397 -1]
                )
                (case_arm
                  pat_list: [{(get-element-attribute)} {(attr)} {(attribute)}]
                  action: [(C {(wd-get-element-attribute)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [401 410 419 -1]
                )
                (case_arm
                  pat_list: [{(get-element-css-value)} {(css-value)}]
                  action: [(C {(wd-get-element-css-value)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [422 427 436 -1]
                )
                (case_arm
                  pat_list: [{(get-element-text)} {(text)}]
                  action: [(C {(wd-get-element-text)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [439 444 453 -1]
                )
                (case_arm
                  pat_list: [{(get-element-tag-name)} {(tag-name)}]
                  action: [(C {(wd-get-element-tag-name)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [456 461 470 -1]
                )
                (case_arm
                  pat_list: [{(is-element-selected)} {(is-selected)}]
                  action: [(C {(wd-is-element-selected)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [474 479 488 -1]
                )
                (case_arm
                  pat_list: [{(is-element-enabled)} {(is-enabled)}]
                  action: [(C {(wd-is-element-enabled)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [491 496 505 -1]
                )
                (case_arm
                  pat_list: [{(element-click)} {(click)}]
                  action: [(C {(wd-element-click)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [509 514 523 -1]
                )
                (case_arm
                  pat_list: [{(element-clear)} {(clear)}]
                  action: [(C {(wd-element-clear)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [526 531 540 -1]
                )
                (case_arm
                  pat_list: [{(element-send-keys)} {(send-keys)}]
                  action: [(C {(wd-element-send-keys)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [543 548 557 -1]
                )
                (case_arm
                  pat_list: [{(execute-script)} {(execute)} {(exec)}]
                  action: [(C {(wd-execute-script-sync)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [561 570 579 -1]
                )
                (case_arm
                  pat_list: [{(execute-script-async)} {(execute-async)} {(exec-async)}]
                  action: [(C {(wd-execute-script-async)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [582 591 600 -1]
                )
                (case_arm
                  pat_list: [{(get-all-cookies)} {(cookies)}]
                  action: [(C {(wd-get-all-cookies)})]
                  spids: [604 609 614 -1]
                )
                (case_arm
                  pat_list: [{(get-named-cookie)} {(cookie)}]
                  action: [(C {(wd-get-named-cookie)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [617 622 631 -1]
                )
                (case_arm
                  pat_list: [{(add-cookie)}]
                  action: [(C {(wd-add-cookie)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [634 635 644 -1]
                )
                (case_arm
                  pat_list: [{(delete-cookie)}]
                  action: [(C {(wd-delete-cookie)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [647 648 657 -1]
                )
                (case_arm
                  pat_list: [{(delete-cookies)}]
                  action: [(C {(wd-delete-cookies)})]
                  spids: [660 661 666 -1]
                )
                (case_arm
                  pat_list: [{(take-screenshot)} {(screenshot)}]
                  action: [(C {(wd-take-screenshot)})]
                  spids: [670 675 680 -1]
                )
                (case_arm
                  pat_list: [{(take-element-screenshot)} {(element-screenshot)}]
                  action: [(C {(wd-take-element-screenshot)} {(DQ ($ Id.VSub_At '$@'))})]
                  spids: [683 688 697 -1]
                )
                (case_arm
                  pat_list: [{(help)}]
                  action: [(C {(print-help)})]
                  spids: [701 702 707 -1]
                )
                (case_arm
                  pat_list: [{(Id.Lit_Star '*')}]
                  action: [
                    (command.Simple
                      words: [{(cat)}]
                      redirects: [
                        (redir.Redir
                          op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:717)
                          fd: -1
                          arg_word: {(2)}
                        )
                        (redir.HereDoc
                          op: (Token id:Id.Redir_DLess val:'<<' span_id:720)
                          fd: -1
                          here_begin: {(.)}
                          here_end_span_id: 726
                          stdin_parts: [('Usage: wd <command> [arguments]\n') ('Help:  wd help\n')]
                        )
                      ]
                    )
                    (command.ControlFlow
                      token: (Token id:Id.ControlFlow_Exit val:exit span_id:728)
                      arg_word: {(1)}
                    )
                  ]
                  spids: [711 712 733 -1]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: die
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rc)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$1')}
                      spids: [748]
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:750)
            )
            (command.Sentence
              child: (C {(shift)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:753)
            )
            (command.Sentence
              child: 
                (command.Simple
                  words: [{(echo)} {(DQ ($ Id.VSub_Number '$0') (':'))} {(DQ ($ Id.VSub_At '$@'))}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_GreatAnd val:'>&' span_id:766)
                      fd: -1
                      arg_word: {(2)}
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:768)
            )
            (command.ControlFlow
              token: (Token id:Id.ControlFlow_Exit val:exit span_id:770)
              arg_word: {(DQ ($ Id.VSub_DollarName '$rc'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: json-obj
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-mJSON) (Id.Lit_Other ':') (Id.Lit_Other ':') (PP)} {(-e)} 
              {
                (SQ (Token id:Id.Lit_Chars val:'\n' span_id:796) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    use List::Util qw(pairmap);\n'
                    span_id: 797
                  ) (Token id:Id.Lit_Chars val:'    $j = JSON::PP->new->allow_nonref;\n' span_id:798) 
                  (Token
                    id: Id.Lit_Chars
                    val: 
'    print "{", join(",", pairmap { $j->encode($a) .":". $b } @ARGV), "}"\n'
                    span_id: 799
                  ) (Token id:Id.Lit_Chars val:'  ' span_id:800)
                )
              } {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: json-arr
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-e)} 
              {
                (SQ (Token id:Id.Lit_Chars val:'\n' span_id:822) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    print "[", join(",", @ARGV), "]"\n'
                    span_id: 823
                  ) (Token id:Id.Lit_Chars val:'  ' span_id:824)
                )
              } {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: json-str
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-mJSON) (Id.Lit_Other ':') (Id.Lit_Other ':') (PP)} {(-e)} 
              {
                (SQ 
                  (Token
                    id: Id.Lit_Chars
                    val: 'print JSON::PP->new->allow_nonref->encode($ARGV[0])'
                    span_id: 851
                  )
                )
              } {(DQ ($ Id.VSub_Number '$1'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: json-get
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-mJSON) (Id.Lit_Other ':') (Id.Lit_Other ':') (PP)} {(-e)} 
              {
                (SQ (Token id:Id.Lit_Chars val:'\n' span_id:878) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    local $/; my $s = <STDIN> || exit 1;\n'
                    span_id: 879
                  ) (Token id:Id.Lit_Chars val:'    my $j = JSON::PP->new->allow_nonref;\n' span_id:880) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    my $data = $j->decode($s);\n'
                    span_id: 881
                  ) (Token id:Id.Lit_Chars val:'    my $x = $data;\n' span_id:882) 
                  (Token id:Id.Lit_Chars val:'    foreach (@ARGV) {\n' span_id:883) (Token id:Id.Lit_Chars val:'      if (ref($x) eq "ARRAY") {\n' span_id:884) 
                  (Token
                    id: Id.Lit_Chars
                    val: '        # convert array to k=>v hash\n'
                    span_id: 885
                  ) (Token id:Id.Lit_Chars val:'        my %h = map { $_ => $x->[$_] } 0..$#$x;\n' span_id:886) 
                  (Token id:Id.Lit_Chars val:'        $x = \\%h;\n' span_id:887) (Token id:Id.Lit_Chars val:'      }\n' span_id:888) 
                  (Token
                    id: Id.Lit_Chars
                    val: '      exists $x->{$_} or die "invalid JSON index";\n'
                    span_id: 889
                  ) (Token id:Id.Lit_Chars val:'      $x = $x->{$_};\n' span_id:890) 
                  (Token id:Id.Lit_Chars val:'    }\n' span_id:891) (Token id:Id.Lit_Chars val:'    print $j->encode($x), "\\n";\n' span_id:892) 
                  (Token id:Id.Lit_Chars val:'  ' span_id:893)
                )
              } {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: json-raw
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-mJSON) (Id.Lit_Other ':') (Id.Lit_Other ':') (PP)} {(-e)} 
              {
                (SQ (Token id:Id.Lit_Chars val:'\n' span_id:920) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    local $/; my $s = <STDIN> || exit 1;\n'
                    span_id: 921
                  ) (Token id:Id.Lit_Chars val:'    my $j = JSON::PP->new->allow_nonref;\n' span_id:922) 
                  (Token id:Id.Lit_Chars val:'    sub flat {\n' span_id:923) (Token id:Id.Lit_Chars val:'      my $x = shift;\n' span_id:924) 
                  (Token
                    id: Id.Lit_Chars
                    val: '      if (ref($x) eq "ARRAY") {\n'
                    span_id: 925
                  ) (Token id:Id.Lit_Chars val:'        flat($_) foreach @$x;\n' span_id:926) 
                  (Token
                    id: Id.Lit_Chars
                    val: '      } elsif (ref($x) eq "HASH") {\n'
                    span_id: 927
                  ) (Token id:Id.Lit_Chars val:'        flat($_) foreach values %$x;\n' span_id:928) 
                  (Token id:Id.Lit_Chars val:'      } else {\n' span_id:929) (Token id:Id.Lit_Chars val:'        print $x, "\\n";\n' span_id:930) 
                  (Token id:Id.Lit_Chars val:'      }\n' span_id:931) (Token id:Id.Lit_Chars val:'    }\n' span_id:932) 
                  (Token
                    id: Id.Lit_Chars
                    val: '    flat $j->decode($s);\n'
                    span_id: 933
                  ) (Token id:Id.Lit_Chars val:'  ' span_id:934)
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: json-raw-nonnull
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(x)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:x)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:953)
                        command_list: (command.CommandList children:[(C {(cat)})])
                      )
                    }
                  spids: [952]
                )
              ]
            )
            (command.Case
              to_match: {($ Id.VSub_DollarName '$x')}
              arms: [
                (case_arm
                  pat_list: [{(null)}]
                  action: [(C {(false)})]
                  spids: [965 966 970 -1]
                )
                (case_arm
                  pat_list: [{(Id.Lit_Star '*')}]
                  action: [
                    (command.Simple
                      words: [{(json-raw)}]
                      redirects: [
                        (redir.Redir
                          op: (Token id:Id.Redir_TLess val:'<<<' span_id:978)
                          fd: -1
                          arg_word: {(DQ ($ Id.VSub_DollarName '$x'))}
                        )
                      ]
                    )
                  ]
                  spids: [973 974 983 -1]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: json-get-raw
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [(C {(json-get)} {(DQ ($ Id.VSub_At '$@'))}) (C {(json-raw)})]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1006)
            )
          ]
        )
    )
    (command.ShFunction
      name: json-get-raw-nonnull
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [(C {(json-get)} {(DQ ($ Id.VSub_At '$@'))}) (C {(json-raw-nonnull)})]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1025)
            )
          ]
        )
    )
    (command.ShFunction
      name: decode-base64
      body: 
        (command.BraceGroup
          children: [
            (C {(perl)} {(-MMIME) (Id.Lit_Other ':') (Id.Lit_Other ':') (Base64)} {(-e)} 
              {(SQ (Token id:Id.Lit_Chars val:'print decode_base64(<STDIN>)' span_id:1047))}
            )
          ]
        )
    )
    (command.ShFunction
      name: hush
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Simple
                  words: [{(DQ ($ Id.VSub_At '$@'))}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_Great val:'>' span_id:1063)
                      fd: -1
                      arg_word: {(/dev/null)}
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1065)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-post
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_eq
                              left: {($ Id.VSub_Pound '$#')}
                              right: {(2)}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1088)
                    )
                  ]
                  action: [
                    (C {(curl)} {(-sSL)} {(-H)} {(DQ ('Content-Type: application/json'))} {(--data-raw)} 
                      {(DQ ($ Id.VSub_Number '$2'))} {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_URL')) (DQ ($ Id.VSub_Number '$1'))}
                    )
                  ]
                  spids: [1077 1090]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_eq
                              left: {($ Id.VSub_Pound '$#')}
                              right: {(1)}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1130)
                    )
                  ]
                  action: [
                    (C {(curl)} {(-sSL)} {(-XPOST)} 
                      {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_URL')) (DQ ($ Id.VSub_Number '$1'))}
                    )
                  ]
                  spids: [1119 1132]
                )
              ]
              else_action: [(C {(die)} {(127)} {(internal)} {(error)})]
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-new-session
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(capabilities)})
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_n
                              child: {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_CAPABILITIES'))}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1189)
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:capabilities)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_CAPABILITIES'))}
                          spids: [1194]
                        )
                      ]
                    )
                  ]
                  spids: [1178 1191]
                )
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_n
                              child: {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_BROWSER'))}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1211)
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:capabilities)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1218)
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {(json-obj)} {(browserName)} 
                                          {
                                            (DQ 
                                              (command_sub
                                                left_token: 
                                                  (Token
                                                    id: Id.Left_DollarParen
                                                    val: '$('
                                                    span_id: 1224
                                                  )
                                                command_list: 
                                                  (command.CommandList
                                                    children: [
                                                      (C {(json-str)} 
                                                        {
                                                          (DQ 
                                                            ($ Id.VSub_DollarName 
'$WEBDRIVER_BROWSER'
                                                            )
                                                          )
                                                        }
                                                      )
                                                    ]
                                                  )
                                              )
                                            )
                                          }
                                        )
                                      ]
                                    )
                                )
                              )
                            }
                          spids: [1216]
                        )
                      ]
                    )
                  ]
                  spids: [1200 1213]
                )
              ]
              else_action: [
                (C {(die)} {(1)} {(DQ ('neither WEBDRIVER_CAPABILITIES nor WEBDRIVER_BROWSER set'))})
              ]
            )
            (command.Pipeline
              children: [
                (C {(wd-post)} {(/session)} 
                  {
                    (DQ 
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1256)
                        command_list: 
                          (command.CommandList
                            children: [
                              (C {(json-obj)} {(desiredCapabilities)} 
                                {(DQ ($ Id.VSub_DollarName '$capabilities'))}
                              )
                            ]
                          )
                      )
                    )
                  }
                )
                (C {(json-get-raw-nonnull)} {(sessionId)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-assert-session
      body: 
        (command.BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_z
                              child: {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_SESSION'))}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1295)
                    )
                  ]
                  action: [(C {(die)} {(1)} {(WEBDRIVER_SESSION)} {(not)} {(defined)})]
                  spids: [1284 1297]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-session
      body: 
        (command.BraceGroup
          children: [
            (C {(wd-assert-session)})
            (C {(curl)} {(-sSL)} 
              {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_URL')) (/session/) 
                (DQ ($ Id.VSub_DollarName '$WEBDRIVER_SESSION')) (DQ ($ Id.VSub_Number '$1'))
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-checked-result
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(result)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:result)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1357)
                        command_list: (command.CommandList children:[(C {(cat)})])
                      )
                    }
                  spids: [1356]
                )
              ]
            )
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:status)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1364)
                          command_list: 
                            (command.CommandList
                              children: [
                                (command.Simple
                                  words: [{(json-get)} {(status)}]
                                  redirects: [
                                    (redir.Redir
                                      op: (Token id:Id.Redir_TLess val:'<<<' span_id:1369)
                                      fd: -1
                                      arg_word: {(DQ ($ Id.VSub_DollarName '$result'))}
                                    )
                                  ]
                                )
                              ]
                            )
                        )
                      )
                    }
                  spids: [1362]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.DBracket
                          expr: 
                            (bool_expr.Binary
                              op_id: Id.BoolBinary_ne
                              left: {($ Id.VSub_DollarName '$status')}
                              right: {(0)}
                            )
                        )
                      terminator: (Token id:Id.Op_Semi val:';' span_id:1388)
                    )
                  ]
                  action: [
                    (C {(die)} {(1)} 
                      {
                        (DQ 
                          (command_sub
                            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1398)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (command.Simple
                                    words: [{(json-get-raw)} {(value)} {(message)}]
                                    redirects: [
                                      (redir.Redir
                                        op: (Token id:Id.Redir_TLess val:'<<<' span_id:1405)
                                        fd: -1
                                        arg_word: {(DQ ($ Id.VSub_DollarName '$result'))}
                                      )
                                    ]
                                  )
                                ]
                              )
                          )
                        )
                      }
                    )
                  ]
                  spids: [1377 1390]
                )
              ]
              else_action: [
                (command.Simple
                  words: [{(json-get)} {(value)}]
                  redirects: [
                    (redir.Redir
                      op: (Token id:Id.Redir_TLess val:'<<<' span_id:1420)
                      fd: -1
                      arg_word: {(DQ ($ Id.VSub_DollarName '$result'))}
                    )
                  ]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-post-session-value
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [
                    (C {(wd-post-session)} {(DQ ($ Id.VSub_At '$@'))})
                    (C {(wd-checked-result)})
                  ]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1446)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-session-simple
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [
                    (C {(wd-get-session)} {(DQ ($ Id.VSub_At '$@'))})
                    (C {(json-get-raw-nonnull)} {(value)})
                  ]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1467)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-session-value
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [(C {(wd-get-session)} {(DQ ($ Id.VSub_At '$@'))}) (C {(wd-checked-result)})]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1486)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-session-value-raw
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [
                    (C {(wd-get-session-value)} {(DQ ($ Id.VSub_At '$@'))})
                    (C {(json-raw-nonnull)})
                  ]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1505)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-element-value
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (C {(wd-get-session-value-raw)} 
                  {(/element/) (DQ ($ Id.VSub_Number '$1')) (/) (DQ ($ Id.VSub_Number '$2'))}
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1525)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-current-url
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-session-simple)} {(/url)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:1539)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-title
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-session-simple)} {(/title)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:1552)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-window-handle
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-session-simple)} {(/window)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:1565)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-page-source
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.Pipeline
                  children: [(C {(wd-get-session-value)} {(/source)}) (C {(json-raw)})]
                  negated: F
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1582)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-delete-session
      body: 
        (command.BraceGroup
          children: [
            (C {(wd-assert-session)})
            (C {(curl)} {(-sSL)} {(-XDELETE)} 
              {(DQ ($ Id.VSub_DollarName '$WEBDRIVER_URL')) (/session/) 
                (DQ ($ Id.VSub_DollarName '$WEBDRIVER_SESSION')) (DQ ($ Id.VSub_Number '$1'))
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-post-session
      body: 
        (command.BraceGroup
          children: [
            (C {(wd-assert-session)})
            (command.Sentence
              child: 
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:url)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$1')}
                      spids: [1627]
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:1629)
            )
            (C {(shift)})
            (command.Pipeline
              children: [
                (C {(wd-post)} 
                  {(/session/) (DQ ($ Id.VSub_DollarName '$WEBDRIVER_SESSION')) 
                    (DQ ($ Id.VSub_DollarName '$url'))
                  } {(DQ ($ Id.VSub_At '$@'))}
                )
                (C {(wd-checked-result)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-go
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} {(/url)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1669)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(url)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1675)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-str)} {(DQ ($ Id.VSub_Number '$1'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-close-window
      body: (command.BraceGroup children:[(C {(hush)} {(wd-delete-session)} {(/window)})])
    )
    (command.ShFunction
      name: wd-switch-to-window
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} {(/window)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1719)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(handle)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1725)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-str)} {(DQ ($ Id.VSub_Number '$1'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-window-handles
      body: 
        (command.BraceGroup
          children: [
            (command.Pipeline
              children: [(C {(wd-get-session)} {(/window/handles)}) (C {(json-get-raw)} {(value)})]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-switch-to-frame
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(id)})
            (command.Case
              to_match: {($ Id.VSub_Number '$1')}
              arms: [
                (case_arm
                  pat_list: [{(Id.Lit_LBracket '[') (0-9) (Id.Lit_RBracket ']')}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:id)
                          op: assign_op.Equal
                          rhs: {($ Id.VSub_Number '$1')}
                          spids: [1784]
                        )
                      ]
                    )
                  ]
                  spids: [1778 1782 1787 -1]
                )
                (case_arm
                  pat_list: [{(Id.Lit_Star '*')}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:id)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1796)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-str)} {(DQ ($ Id.VSub_Number '$1'))})]
                                    )
                                )
                              )
                            }
                          spids: [1794]
                        )
                      ]
                    )
                  ]
                  spids: [1790 1792 1805 -1]
                )
              ]
            )
            (C {(hush)} {(wd-post-session)} {(/frame)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1818)
                    command_list: 
                      (command.CommandList
                        children: [(C {(json-obj)} {(id)} {(DQ ($ Id.VSub_DollarName '$id'))})]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-switch-to-top-level-frame
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} {(frame)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1846)
                    command_list: (command.CommandList children:[(C {(json-obj)} {(id)} {(null)})])
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-window-size
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(result)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:result)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1871)
                        command_list: 
                          (command.CommandList
                            children: [(C {(wd-get-session)} {(/window/size)})]
                          )
                      )
                    }
                  spids: [1870]
                )
              ]
            )
            (command.Pipeline
              children: [
                (C {(echo)} {(DQ ($ Id.VSub_DollarName '$result'))})
                (C {(json-get-raw)} {(value)} {(width)})
              ]
              negated: F
            )
            (command.Pipeline
              children: [
                (C {(echo)} {(DQ ($ Id.VSub_DollarName '$result'))})
                (C {(json-get-raw)} {(value)} {(height)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-set-window-size
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} {(/window/size)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1924)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(width)} {(DQ ($ Id.VSub_Number '$1'))} {(height)} 
                            {(DQ ($ Id.VSub_Number '$2'))}
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-maximize
      body: (command.BraceGroup children:[(C {(hush)} {(wd-post-session)} {(/window/maximize)})])
    )
    (command.ShFunction
      name: wd-parse-strategy
      body: 
        (command.BraceGroup
          children: [
            (command.Case
              to_match: {($ Id.VSub_Number '$1')}
              arms: [
                (case_arm
                  pat_list: [{(id)}]
                  action: [(C {(json-str)} {(DQ (id))})]
                  spids: [1974 1975 1983 -1]
                )
                (case_arm
                  pat_list: [{(name)}]
                  action: [(C {(json-str)} {(DQ (name))})]
                  spids: [1986 1987 1995 -1]
                )
                (case_arm
                  pat_list: [{(class) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(DQ ('class name'))})]
                  spids: [1998 2000 2008 -1]
                )
                (case_arm
                  pat_list: [{(tag) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(DQ ('tag name'))})]
                  spids: [2011 2013 2021 -1]
                )
                (case_arm
                  pat_list: [{(css) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(DQ ('css selector'))})]
                  spids: [2024 2026 2034 -1]
                )
                (case_arm
                  pat_list: [{(link) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(DQ ('link text'))})]
                  spids: [2037 2039 2047 -1]
                )
                (case_arm
                  pat_list: [{(partial) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(DQ ('partial link text'))})]
                  spids: [2050 2052 2060 -1]
                )
                (case_arm
                  pat_list: [{(xpath) (Id.Lit_Star '*')}]
                  action: [(C {(json-str)} {(xpath)})]
                  spids: [2063 2065 2071 -1]
                )
                (case_arm
                  pat_list: [{(Id.Lit_Star '*')}]
                  action: [
                    (C {(die)} {(1)} {(unknown)} {(element)} {(location)} {(strategy) (Id.Lit_Other ':')} 
                      {(DQ ($ Id.VSub_Number '$1'))}
                    )
                  ]
                  spids: [2074 2075 -1 2095]
                )
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-general-element-find
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(local)} {(Id.Lit_VarLike 'path=') (DQ ($ Id.VSub_Number '$1'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2113)
            )
            (C {(shift)})
            (C {(local)} {(strategy)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:strategy)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (DQ 
                        (command_sub
                          left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2125)
                          command_list: 
                            (command.CommandList
                              children: [(C {(wd-parse-strategy)} {(DQ ($ Id.VSub_Number '$1'))})]
                            )
                        )
                      )
                    }
                  spids: [2123]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_eq
                      left: {($ Id.VSub_QMark '$?')}
                      right: {(0)}
                    )
                )
                (command.ControlFlow
                  token: (Token id:Id.ControlFlow_Exit val:exit span_id:2147)
                  arg_word: {($ Id.VSub_QMark '$?')}
                )
              ]
            )
            (C {(shift)})
            (C {(local)} {(value)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:value)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2161)
                        command_list: 
                          (command.CommandList
                            children: [(C {(json-str)} {(DQ ($ Id.VSub_Star '$*'))})]
                          )
                      )
                    }
                  spids: [2160]
                )
              ]
            )
            (command.Pipeline
              children: [
                (C {(wd-post-session)} {(DQ ($ Id.VSub_DollarName '$path'))} 
                  {
                    (DQ 
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2177)
                        command_list: 
                          (command.CommandList
                            children: [
                              (C {(json-obj)} {(using)} {(DQ ($ Id.VSub_DollarName '$strategy'))} 
                                {(value)} {(DQ ($ Id.VSub_DollarName '$value'))}
                              )
                            ]
                          )
                      )
                    )
                  }
                )
                (C {(json-raw)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-find-element
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-general-element-find)} {(/element)} {(DQ ($ Id.VSub_At '$@'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2215)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-find-elements
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-general-element-find)} {(/elements)} {(DQ ($ Id.VSub_At '$@'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2232)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-find-element-from-element
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(local)} {(Id.Lit_VarLike 'element=') ($ Id.VSub_Number '$1')})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2248)
            )
            (C {(shift)})
            (C {(wd-general-element-find)} 
              {(/element/) (DQ ($ Id.VSub_DollarName '$element')) (/element)} {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-find-elements-from-element
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(local)} {(Id.Lit_VarLike 'element=') ($ Id.VSub_Number '$1')})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2279)
            )
            (C {(shift)})
            (C {(wd-general-element-find)} 
              {(/element/) (DQ ($ Id.VSub_DollarName '$element')) (/elements)} {(DQ ($ Id.VSub_At '$@'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-element-attribute
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(x)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:x)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2312)
                        command_list: 
                          (command.CommandList
                            children: [
                              (C {(wd-get-session-value-raw)} 
                                {(/element/) (DQ ($ Id.VSub_Number '$1')) (/attribute/) 
                                  (DQ ($ Id.VSub_Number '$2'))
                                }
                              )
                            ]
                          )
                      )
                    }
                  spids: [2311]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_eq
                      left: {($ Id.VSub_QMark '$?')}
                      right: {(0)}
                    )
                )
                (C {(die)} {(1)} {(DQ ('attribute not found'))})
              ]
            )
            (C {(echo)} {(DQ ($ Id.VSub_DollarName '$x'))})
          ]
        )
    )
    (command.ShFunction
      name: wd-get-element-css-value
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(x)})
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:x)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2369)
                        command_list: 
                          (command.CommandList
                            children: [
                              (C {(wd-get-session-value-raw)} 
                                {(/element/) (DQ ($ Id.VSub_Number '$1')) (/css/) 
                                  (DQ ($ Id.VSub_Number '$2'))
                                }
                              )
                            ]
                          )
                      )
                    }
                  spids: [2368]
                )
              ]
            )
            (command.AndOr
              ops: [Id.Op_DPipe]
              children: [
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_eq
                      left: {($ Id.VSub_QMark '$?')}
                      right: {(0)}
                    )
                )
                (C {(die)} {(1)} {(DQ ('CSS property not found'))})
              ]
            )
            (C {(echo)} {(DQ ($ Id.VSub_DollarName '$x'))})
          ]
        )
    )
    (command.ShFunction
      name: wd-get-element-text
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-element-value)} {(DQ ($ Id.VSub_Number '$1'))} {(text)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2426)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-element-tag-name
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-element-value)} {(DQ ($ Id.VSub_Number '$1'))} {(name)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2443)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-is-element-enabled
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_eq
                      left: {(1)}
                      right: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2460)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (C {(wd-get-element-value)} {(DQ ($ Id.VSub_Number '$1'))} {(enabled)})
                                ]
                              )
                          )
                        }
                    )
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:2471)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-is-element-selected
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_eq
                      left: {(1)}
                      right: 
                        {
                          (command_sub
                            left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2487)
                            command_list: 
                              (command.CommandList
                                children: [
                                  (C {(wd-get-element-value)} {(DQ ($ Id.VSub_Number '$1'))} 
                                    {(selected)}
                                  )
                                ]
                              )
                          )
                        }
                    )
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:2498)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-element-simple-action
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} 
              {(/element/) (DQ ($ Id.VSub_Number '$1')) (/) (DQ ($ Id.VSub_Number '$2'))}
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-element-click
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-element-simple-action)} {(DQ ($ Id.VSub_Number '$1'))} {(click)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2539)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-element-clear
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-element-simple-action)} {(DQ ($ Id.VSub_Number '$1'))} {(clear)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2556)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-element-send-keys
      body: 
        (command.BraceGroup
          children: [
            (C {(local)} {(element)})
            (command.Sentence
              child: 
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:element)
                      op: assign_op.Equal
                      rhs: {($ Id.VSub_Number '$1')}
                      spids: [2573]
                    )
                  ]
                )
              terminator: (Token id:Id.Op_Semi val:';' span_id:2575)
            )
            (C {(shift)})
            (C {(wd-element-simple-action)} {(DQ ($ Id.VSub_DollarName '$element'))} {(value)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2589)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(value)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2595)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-str)} {(DQ ($ Id.VSub_Star '$*'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-execute-script-sync
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(local)} {(Id.Lit_VarLike 'script=') (DQ ($ Id.VSub_Number '$1'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2622)
            )
            (C {(shift)})
            (C {(wd-post-session)} {(/execute/sync)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2632)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(script)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2640)
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {(json-str)} {(DQ ($ Id.VSub_DollarName '$script'))})
                                      ]
                                    )
                                )
                              )
                            } {(args)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2654)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-arr)} {(DQ ($ Id.VSub_At '$@'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-execute-script-async
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(local)} {(Id.Lit_VarLike 'script=') (DQ ($ Id.VSub_Number '$1'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2684)
            )
            (C {(shift)})
            (C {(wd-post-session)} {(/execute/async)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2694)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(script)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2702)
                                  command_list: 
                                    (command.CommandList
                                      children: [
                                        (C {(json-str)} {(DQ ($ Id.VSub_DollarName '$script'))})
                                      ]
                                    )
                                )
                              )
                            } {(args)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2716)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-arr)} {(DQ ($ Id.VSub_At '$@'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-all-cookies
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-session-value)} {(/cookie)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2742)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-get-named-cookie
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-get-session-value)} {(/cookie/) (DQ ($ Id.VSub_Number '$1'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2758)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-add-cookie
      body: 
        (command.BraceGroup
          children: [
            (C {(hush)} {(wd-post-session)} {(/cookie)} 
              {
                (DQ 
                  (command_sub
                    left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2777)
                    command_list: 
                      (command.CommandList
                        children: [
                          (C {(json-obj)} {(cookie)} 
                            {
                              (DQ 
                                (command_sub
                                  left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:2783)
                                  command_list: 
                                    (command.CommandList
                                      children: [(C {(json-obj)} {(DQ ($ Id.VSub_At '$@'))})]
                                    )
                                )
                              )
                            }
                          )
                        ]
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-delete-cookie
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-delete-session)} {(/cookie/) (DQ ($ Id.VSub_Number '$1'))})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2809)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-delete-cookies
      body: 
        (command.BraceGroup
          children: [
            (command.Sentence
              child: (C {(wd-delete-session)} {(/cookie)})
              terminator: (Token id:Id.Op_Semi val:';' span_id:2822)
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-take-screenshot
      body: 
        (command.BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {(wd-get-session-value)} {(/screenshot)})
                (C {(json-raw)})
                (C {(decode-base64)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: wd-take-element-screenshot
      body: 
        (command.BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {(wd-get-session-value)} {(/element/) (DQ ($ Id.VSub_Number '$1')) (/screenshot)})
                (C {(json-raw)})
                (C {(decode-base64)})
              ]
              negated: F
            )
          ]
        )
    )
    (command.ShFunction
      name: print-help
      body: 
        (command.BraceGroup
          children: [
            (command.Simple
              words: [{(cat)}]
              redirects: [
                (redir.HereDoc
                  op: (Token id:Id.Redir_DLess val:'<<' span_id:2884)
                  fd: -1
                  here_begin: {(SQ (Token id:Id.Lit_Chars val:. span_id:2886))}
                  here_end_span_id: 3165
                  stdin_parts: [
                    ('# wd -- WebDriver command line tool\n')
                    ('\n')
                    ('`wd` is a simple tool for interacting with servers that implement the\n')
                    ('W3C WebDriver API.\n')
                    ('\n')
                    ('It can be used for web automation tasks such as testing and scraping.\n')
                    ('\n')
                    ('You can use [Selenium](http://www.seleniumhq.org/) as the WebDriver server\n')
                    ('to control browsers on your own machine.\n')
                    ('\n')
                    ('There are commercial services that offer the WebDriver API remotely; see\n')
                    ('"Functional Test Services" [here](http://www.seleniumhq.org/ecosystem/).\n')
                    ('\n')
                    (
'See [the WebDriver spec](https://w3c.github.io/webdriver/webdriver-spec.html)\n'
                    )
                    ('for details about the protocol and behavior.\n')
                    ('\n')
                    ('## Dependencies\n')
                    ('\n')
                    ('  - `bash`\n')
                    ('  - `perl` (5.14 or greater)\n')
                    ('  - `curl`\n')
                    ('\n')
                    ('## Example session\n')
                    ('\n')
                    ('    $ export WEBDRIVER_BROWSER=chrome\n')
                    ('    $ export WEBDRIVER_SESSION="$(wd new-session)"\n')
                    ('    $ wd go https://github.com/mbrock/wd\n')
                    ('    $ wd screenshot > /tmp/wd.png\n')
                    ('    $ wd click "$(wd find css .user-mention)"\n')
                    ("    $ wd exec 'return document.title'\n")
                    ('\n')
                    ('## Configuration\n')
                    ('\n')
                    (
'  - `WEBDRIVER_URL`: WebDriver API URL (default `http://127.0.0.1:4444/wd/hub`)\n'
                    )
                    ('\n')
                    ('## Command reference\n')
                    ('\n')
                    ('### Managing sessions\n')
                    ('\n')
                    ('#### `wd new-session`\n')
                    ('\n')
                    ('Prints the new session ID.\n')
                    ('\n')
                    ('All other commands expect this ID to be in `WEBDRIVER_SESSION`, so\n')
                    ('\n')
                    ('    export WEBDRIVER_SESSION="$(wd new-session)"\n')
                    ('\n')
                    ('is a useful pattern.\n')
                    ('\n')
                    ('You must configure desired capabilities by setting either\n')
                    ('\n')
                    ('  - `WEBDRIVER_CAPABILITIES` to a stringified JSON object, or\n')
                    ('  - `WEBDRIVER_BROWSER` to a browser name (`chrome`, `firefox`, etc).\n')
                    ('\n')
                    ('#### `wd delete-session`\n')
                    ('\n')
                    ('Deletes the current session.\n')
                    ('\n')
                    ('### Navigation\n')
                    ('\n')
                    ('#### `wd go <url>`\n')
                    ('\n')
                    ('Opens `<url>` in the current window.\n')
                    ('\n')
                    ('#### `wd back`\n')
                    ('\n')
                    ('Navigates back in the current window.\n')
                    ('\n')
                    ('#### `wd forward`\n')
                    ('\n')
                    ('Navigates forward in the current window.\n')
                    ('\n')
                    ('#### `wd refresh`\n')
                    ('\n')
                    ('Refreshes the page of the current window.\n')
                    ('\n')
                    ('### Element finding\n')
                    ('\n')
                    ('#### `wd find <strategy> <selector> ...`\n')
                    ('\n')
                    ('Finds one matching element and prints its element ID.\n')
                    ('\n')
                    ('The `<strategy>` can be one of:\n')
                    ('\n')
                    ('  - `css` (CSS selector)\n')
                    ('  - `xpath` (XPath selector)\n')
                    ('  - `id` (element ID)\n')
                    ('  - `name` (element name)\n')
                    ('  - `class` (element class name)\n')
                    ('  - `tag` (element tag name)\n')
                    ('  - `link` (element link text)\n')
                    ('  - `partial` (partial element link text)\n')
                    ('\n')
                    ('The `<selector>` values are concatenated for convenience.\n')
                    ('\n')
                    ('Example:\n')
                    ('\n')
                    ('    $ wd find css article header img.avatar\n')
                    ('\n')
                    ('#### `wd find-all <strategy> <selector> ...`\n')
                    ('\n')
                    ('See `wd find`; finds all matching elements.\n')
                    ('\n')
                    ('#### `wd find-in <element-id> <strategy> <selector> ...`\n')
                    ('\n')
                    ('See `wd find`; finds one matching sub-element.\n')
                    ('\n')
                    ('#### `wd find-all-in <element-id> <strategy> <selector> ...`\n')
                    ('\n')
                    ('See `wd find`; finds all matching sub-elements.\n')
                    ('\n')
                    ('### Element information\n')
                    ('\n')
                    ('#### `wd is-selected <element-id>`\n')
                    ('\n')
                    ('Exits with a non-zero status if the element is not a selected or\n')
                    ('checked `input` or `option`.\n')
                    ('\n')
                    ('#### `wd is-enabled <element-id>`\n')
                    ('\n')
                    ('Exits with a non-zero status if the element is not an enabled\n')
                    ('form control.\n')
                    ('\n')
                    ('#### `wd attribute <element-id> <attribute-name>`\n')
                    ('\n')
                    ('Prints an element attribute value.\n')
                    ('\n')
                    ('Exits with non-zero status if the given attribute does not exist.\n')
                    ('\n')
                    ('#### `wd css-value <element-id> <css-property-name>`\n')
                    ('\n')
                    ('Prints an element CSS property value.\n')
                    ('\n')
                    ('Exits with non-zero status if the given style property does not exist.\n')
                    ('\n')
                    ('#### `wd text <element-id>`\n')
                    ('\n')
                    ("Prints an element's `innerText`.\n")
                    ('\n')
                    ('#### `wd tag-name <element-id>`\n')
                    ('\n')
                    ('Prints the tag name of an element.\n')
                    ('\n')
                    ('### Element actions\n')
                    ('\n')
                    ('#### `wd click <element-id>`\n')
                    ('\n')
                    ('Clicks an element.\n')
                    ('\n')
                    ('#### `wd clear <element-id>`\n')
                    ('\n')
                    ('Clears the value, checkedness, or text content of an element.\n')
                    ('\n')
                    ('#### `wd send-keys <element-id> [keys] ...`\n')
                    ('\n')
                    ('Sends keys to an element.\n')
                    ('\n')
                    ('Key arguments are concatenated for convenience.\n')
                    ('\n')
                    ('Example:\n')
                    ('\n')
                    ('    $ wd send-keys "$(wd find id search)" webdriver json api\n')
                    ('\n')
                    ('### JavaScript execution\n')
                    ('\n')
                    ('#### `wd execute <body> [argument] ...`\n')
                    ('\n')
                    ('Evaluates the JavaScript code `<body>` as a function called with the\n')
                    ('given arguments.\n')
                    ('\n')
                    ('Prints the return value of the specified function.\n')
                    ('\n')
                    ('#### `wd execute-async <body> [argument] ...`\n')
                    ('\n')
                    (
'Evaluates as in `wd execute` but waiting for the script to invoke a callback\n'
                    )
                    ('which is passed as an additional final argument to the specified function.\n')
                    ('\n')
                    ('Prints the value finally passed to the callback.\n')
                    ('\n')
                    ('### Page information\n')
                    ('\n')
                    ('#### `wd get-current-url`\n')
                    ('\n')
                    ('Prints the URL of the page in the current window.\n')
                    ('\n')
                    ('#### `wd get-title`\n')
                    ('\n')
                    ('Prints the title of the page in the current window.\n')
                    ('\n')
                    ('#### `wd get-page-source`\n')
                    ('\n')
                    ('Prints the raw HTML source of the page in the current window.\n')
                    ('\n')
                    ('### Windows\n')
                    ('\n')
                    ('#### `wd get-window-size`\n')
                    ('\n')
                    ("Prints the current window's width and height on separate lines.\n")
                    ('\n')
                    ('#### `wd set-window-size <width> <height>`\n')
                    ('\n')
                    ('Changes the size of the current window.\n')
                    ('\n')
                    ('#### `wd maximize`\n')
                    ('\n')
                    ('Maximizes the current window.\n')
                    ('\n')
                    ('#### `wd get-window-handle`\n')
                    ('\n')
                    ('Prints the window handle of the current window.\n')
                    ('\n')
                    ('#### `wd get-window-handles`\n')
                    ('\n')
                    ('Prints a list of all window handles in the current session.\n')
                    ('\n')
                    ('#### `wd switch-to-window <window-handle>`\n')
                    ('\n')
                    ('Changes which window is the current window.\n')
                    ('\n')
                    ('### Frames\n')
                    ('\n')
                    ('#### `wd switch-to-frame <frame-id>`\n')
                    ('\n')
                    ('Changes the current frame.\n')
                    ('\n')
                    ('`<frame-id>` can be either a number or an element ID.\n')
                    ('\n')
                    ('See [the specification](https://www.w3.org/TR/webdriver/#switch-to-frame)\n')
                    ('for exact details.\n')
                    ('\n')
                    ('#### `wd switch-to-top-level-frame`\n')
                    ('\n')
                    ('Resets the current frame to the top level.\n')
                    ('\n')
                    ('#### `wd switch-to-parent-frame`\n')
                    ('\n')
                    ('Sets the current frame to the parent of the current frame.\n')
                    ('\n')
                    ('### Cookies\n')
                    ('\n')
                    (
'See [the spec](https://w3c.github.io/webdriver/webdriver-spec.html#cookies)\n'
                    )
                    ('for details on cookie JSON serialization.\n')
                    ('\n')
                    ('#### `wd cookies`\n')
                    ('\n')
                    ('Prints the currently set cookies as a JSON array.\n')
                    ('\n')
                    ('#### `wd cookie <name>`\n')
                    ('\n')
                    ('Prints the cookie named `<name>` as JSON.\n')
                    ('\n')
                    ('#### `wd add-cookie <key> <value> <key> <value> ...`\n')
                    ('\n')
                    ('Adds a cookie according to the given keys/values.\n')
                    ('\n')
                    ('Example: `wd add-cookie name \'"user"\' value \'"mbrock"\'`\n')
                    ('\n')
                    ('#### `wd delete-cookie <name>`\n')
                    ('\n')
                    ('Deletes the cookie whose name is `<name>`.\n')
                    ('\n')
                    ('#### `wd delete-cookies`\n')
                    ('\n')
                    ('Deletes all cookies.\n')
                    ('\n')
                    ('### Screenshots\n')
                    ('\n')
                    ('#### `wd screenshot`\n')
                    ('\n')
                    ('Prints a binary PNG screenshot to stdout.\n')
                    ('\n')
                    ('#### `wd element-screenshot <element-id>`\n')
                    ('\n')
                    ('Prints a binary PNG screenshot of a specific element to stdout.\n')
                    ('\n')
                    ('(Not supported by Chrome.)\n')
                  ]
                )
              ]
            )
          ]
        )
    )
    (C {(main)} {(DQ ($ Id.VSub_At '$@'))})
  ]
)