ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-WebDriver/WebDriver.pm
(Generate patch)

Comparing AnyEvent-WebDriver/WebDriver.pm (file contents):
Revision 1.51 by root, Fri Mar 27 17:05:50 2020 UTC vs.
Revision 1.52 by root, Fri Mar 27 17:50:16 2020 UTC

1426 my ($self, $source) = @_; 1426 my ($self, $source) = @_;
1427 1427
1428 $self->_add ($source, ptr => "pointerCancel") 1428 $self->_add ($source, ptr => "pointerCancel")
1429} 1429}
1430 1430
1431=item $al = $al->keyDown ($key, $source) 1431=item $al = $al->key_down ($key, $source)
1432 1432
1433=item $al = $al->keyUp ($key, $source) 1433=item $al = $al->key_up ($key, $source)
1434 1434
1435Press or release the given key. 1435Press or release the given key.
1436 1436
1437=item $al = $al->key ($key, $source) 1437=item $al = $al->key ($key, $source)
1438 1438
1439Peess and release the given key, without unnecessary delay. 1439Peess and release the given key in one go, without unnecessary delay.
1440 1440
1441A special syntax, C<{keyname}> can be used for special keys - all the special key names from 1441A special syntax, C<{keyname}> can be used for special keys -
1442all the special key names from L<the second table in section
1442L<section 17.4.2|https://www.w3.org/TR/webdriver1/#keyboard-actions> of the WebDriver recommendation 144317.4.2|https://www.w3.org/TR/webdriver1/#keyboard-actions> of the
1443can be used. 1444WebDriver recommendation can be used - prefix with C<Shift-Space>. to get
1445the shifted version, as in C<Shift-
1444 1446
1445Example: press and release "a". 1447Example: press and release "a".
1446 1448
1447 $al->key ("a"); 1449 $al->key ("a");
1448 1450
1461cluster. There is no syntax for special keys, everything will be typed 1463cluster. There is no syntax for special keys, everything will be typed
1462"as-is" if possible. 1464"as-is" if possible.
1463 1465
1464=cut 1466=cut
1465 1467
1468# copy&paste form the spec via browser, with OSxxx replaces by Metaxxx
1469our $SPECIAL_KEY = <<'EOF';
1470"`" "~" "Backquote"
1471"\" "|" "Backslash"
1472"\uE003" "Backspace"
1473"[" "{" "BracketLeft"
1474"]" "}" "BracketRight"
1475"," "<" "Comma"
1476"0" ")" "Digit0"
1477"1" "!" "Digit1"
1478"2" "@" "Digit2"
1479"3" "#" "Digit3"
1480"4" "$" "Digit4"
1481"5" "%" "Digit5"
1482"6" "^" "Digit6"
1483"7" "&" "Digit7"
1484"8" "*" "Digit8"
1485"9" "(" "Digit9"
1486"=" "+" "Equal"
1487"<" ">" "IntlBackslash"
1488"a" "A" "KeyA"
1489"b" "B" "KeyB"
1490"c" "C" "KeyC"
1491"d" "D" "KeyD"
1492"e" "E" "KeyE"
1493"f" "F" "KeyF"
1494"g" "G" "KeyG"
1495"h" "H" "KeyH"
1496"i" "I" "KeyI"
1497"j" "J" "KeyJ"
1498"k" "K" "KeyK"
1499"l" "L" "KeyL"
1500"m" "M" "KeyM"
1501"n" "N" "KeyN"
1502"o" "O" "KeyO"
1503"p" "P" "KeyP"
1504"q" "Q" "KeyQ"
1505"r" "R" "KeyR"
1506"s" "S" "KeyS"
1507"t" "T" "KeyT"
1508"u" "U" "KeyU"
1509"v" "V" "KeyV"
1510"w" "W" "KeyW"
1511"x" "X" "KeyX"
1512"y" "Y" "KeyY"
1513"z" "Z" "KeyZ"
1514"-" "_" "Minus"
1515"." ">"." "Period"
1516"'" """ "Quote"
1517";" ":" "Semicolon"
1518"/" "?" "Slash"
1519"\uE00A" "AltLeft"
1520"\uE052" "AltRight"
1521"\uE009" "ControlLeft"
1522"\uE051" "ControlRight"
1523"\uE006" "Enter"
1524"\uE03D" "OSLeft"
1525"\uE053" "OSRight"
1526"\uE008" "ShiftLeft"
1527"\uE050" "ShiftRight"
1528" " "\uE00D" "Space"
1529"\uE004" "Tab"
1530"\uE017" "Delete"
1531"\uE010" "End"
1532"\uE002" "Help"
1533"\uE011" "Home"
1534"\uE016" "Insert"
1535"\uE00F" "PageDown"
1536"\uE00E" "PageUp"
1537"\uE015" "ArrowDown"
1538"\uE012" "ArrowLeft"
1539"\uE014" "ArrowRight"
1540"\uE013" "ArrowUp"
1541"\uE00C" "Escape"
1542"\uE031" "F1"
1543"\uE032" "F2"
1544"\uE033" "F3"
1545"\uE034" "F4"
1546"\uE035" "F5"
1547"\uE036" "F6"
1548"\uE037" "F7"
1549"\uE038" "F8"
1550"\uE039" "F9"
1551"\uE03A" "F10"
1552"\uE03B" "F11"
1553"\uE03C" "F12"
1554"\uE01A" "\uE05C" "Numpad0"
1555"\uE01B" "\uE056" "Numpad1"
1556"\uE01C" "\uE05B" "Numpad2"
1557"\uE01D" "\uE055" "Numpad3"
1558"\uE01E" "\uE058" "Numpad4"
1559"\uE01F" "Numpad5"
1560"\uE020" "\uE05A" "Numpad6"
1561"\uE021" "\uE057" "Numpad7"
1562"\uE022" "\uE059" "Numpad8"
1563"\uE023" "\uE054" "Numpad9"
1564"\uE025" "NumpadAdd"
1565"\uE026" "NumpadComma"
1566"\uE028" "\uE05D" "NumpadDecimal"
1567"\uE029" "NumpadDivide"
1568"\uE007" "NumpadEnter"
1569"\uE024" "NumpadMultiply"
1570"\uE027" "NumpadSubtract"
1571
1572"\uE03D" "MetaLeft"
1573"\uE053" "MetaRight"
1574EOF
1575
1466our %SPECIAL_KEY = ( 1576our %SPECIAL_KEY;
1467# "NULL" => \xE000, 1577
1468 "Unidentified" => 0xE000, 1578sub _special_key($) {
1469 "Cancel" => 0xE001, 1579 # parse first time
1470 "Help" => 0xE002, 1580 %SPECIAL_KEY || do {
1471 "Backspace" => 0xE003, 1581 for (split /\n/, $SPECIAL_KEY) {
1472 "Tab" => 0xE004, 1582 s/"//g or next;
1473 "Clear" => 0xE005, 1583 my ($k, $s, $name) = split /\t/;
1474 "Return" => 0xE006, 1584
1475 "Enter" => 0xE007, 1585 # unescape \uXXXX, convert string to codepoint
1476 "Shift" => 0xE008, 1586 $_ = /^\\u/ ? hex substr $_, 2 : ord
1477 "Control" => 0xE009, 1587 for $k, $s;
1478 "Alt" => 0xE00A, 1588
1479 "Pause" => 0xE00B, 1589 $SPECIAL_KEY{$name} = $k;
1480 "Escape" => 0xE00C, 1590 $SPECIAL_KEY{"Shift-$name"} = $s if $s;
1481 " " => 0xE00D, 1591
1482 "PageUp" => 0xE00E, 1592 }
1483 "PageDown" => 0xE00F, 1593
1484 "End" => 0xE010, 1594 undef $SPECIAL_KEY; # save memory
1485 "Home" => 0xE011, 1595 };
1486 "ArrowLeft" => 0xE012, 1596
1487 "ArrowUp" => 0xE013, 1597 exists $SPECIAL_KEY{$_[0]}
1488 "ArrowRight" => 0xE014, 1598 ? chr $SPECIAL_KEY{$_[0]}
1489 "ArrowDown" => 0xE015, 1599 : Carp::croak "AnyEvent::WebDriver::Actions: special key '$1' not known"
1490 "Insert" => 0xE016, 1600}
1491 "Delete" => 0xE017,
1492 ";" => 0xE018,
1493 "=" => 0xE019,
1494 "0" => 0xE01A,
1495 "1" => 0xE01B,
1496 "2" => 0xE01C,
1497 "3" => 0xE01D,
1498 "4" => 0xE01E,
1499 "5" => 0xE01F,
1500 "6" => 0xE020,
1501 "7" => 0xE021,
1502 "8" => 0xE022,
1503 "9" => 0xE023,
1504 "*" => 0xE024,
1505 "+" => 0xE025,
1506 "," => 0xE026,
1507 "-" => 0xE027,
1508 "." => 0xE028,
1509 "/" => 0xE029,
1510 "F1" => 0xE031,
1511 "F2" => 0xE032,
1512 "F3" => 0xE033,
1513 "F4" => 0xE034,
1514 "F5" => 0xE035,
1515 "F6" => 0xE036,
1516 "F7" => 0xE037,
1517 "F8" => 0xE038,
1518 "F9" => 0xE039,
1519 "F10" => 0xE03A,
1520 "F11" => 0xE03B,
1521 "F12" => 0xE03C,
1522 "Meta" => 0xE03D,
1523 "ZenkakuHankaku" => 0xE040,
1524 "Shift" => 0xE050,
1525 "Control" => 0xE051,
1526 "Alt" => 0xE052,
1527 "Meta" => 0xE053,
1528 "PageUp" => 0xE054,
1529 "PageDown" => 0xE055,
1530 "End" => 0xE056,
1531 "Home" => 0xE057,
1532 "ArrowLeft" => 0xE058,
1533 "ArrowUp" => 0xE059,
1534 "ArrowRight" => 0xE05A,
1535 "ArrowDown" => 0xE05B,
1536 "Insert" => 0xE05C,
1537 "Delete" => 0xE05D,
1538);
1539 1601
1540sub _kv($) { 1602sub _kv($) {
1541 $_[0] =~ /^\{(.*)\}$/s 1603 $_[0] =~ /^\{(.*)\}$/s
1542 ? (exists $SPECIAL_KEY{$1} 1604 ? _special_key $1
1543 ? chr $SPECIAL_KEY{$1}
1544 : Carp::croak "AnyEvent::WebDriver::Actions: special key '$1' not known")
1545 : $_[0] 1605 : $_[0]
1546} 1606}
1547 1607
1548sub key_down { 1608sub key_down {
1549 my ($self, $key, $source) = @_; 1609 my ($self, $key, $source) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines