Commands.pm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package Selenium::Remote::Mock::Commands;
  2. # ABSTRACT: utility class to mock Selenium::Remote::Commands
  3. #
  4. use Moo;
  5. extends 'Selenium::Remote::Commands';
  6. # override get_params so we do not rewrite the parameters
  7. sub get_params {
  8. my $self = shift;
  9. my $args = shift;
  10. my $data = {};
  11. my $command = delete $args->{command};
  12. $data->{'url'} = $self->get_url($command);
  13. $data->{'method'} = $self->get_method($command);
  14. $data->{'no_content_success'} = $self->get_no_content_success($command);
  15. $data->{'url_params'} = $args;
  16. return $data;
  17. }
  18. sub get_method_name_from_parameters {
  19. my $self = shift;
  20. my $params = shift;
  21. my $method_name = '';
  22. my $cmds = $self->get_cmds();
  23. foreach my $cmd (keys %{$cmds}) {
  24. if (($cmds->{$cmd}->{method} eq $params->{method}) && ($cmds->{$cmd}->{url} eq $params->{url})) {
  25. $method_name = $cmd;
  26. last;
  27. }
  28. }
  29. return $method_name;
  30. }
  31. 1;
  32. __END__
  33. =pod
  34. =head1 DESCRIPTION
  35. Utility class to be for testing purposes, with L<Selenium::Remote::Mock::RemoteConnection> only.
  36. =cut