1
0

WebElement.pm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package Selenium::Remote::WebElement;
  2. use strict;
  3. use warnings;
  4. use Data::Dumper;
  5. # This is the already instantiated Driver object, which will be passed to the
  6. # constructor when this class is instantiated.
  7. my $driver;
  8. sub new {
  9. my ($class, $id, $parent) = @_;
  10. $driver = $parent;
  11. my $self = {
  12. id => $id,
  13. };
  14. bless $self, $class or die "Can't bless $class: $!";
  15. return $self;
  16. }
  17. sub click {
  18. my ($self) = @_;
  19. my $res = { 'command' => 'clickElement', 'id' => $self->{id} };
  20. return $driver->_execute_command($res);
  21. }
  22. sub get_value {
  23. my ($self) = @_;
  24. my $res = { 'command' => 'getElementValue', 'id' => $self->{id} };
  25. return $driver->_execute_command($res);
  26. }
  27. sub submit {
  28. my ($self) = @_;
  29. my $res = { 'command' => 'submitElement', 'id' => $self->{id} };
  30. return $driver->_execute_command($res);
  31. }
  32. sub send_keys {
  33. my ($self, $string) = @_;
  34. my $res = { 'command' => 'sendKeysToElement', 'id' => $self->{id} };
  35. my $params = {
  36. 'value' => $string
  37. };
  38. return $driver->_execute_command($res, $params);
  39. }
  40. 1;