Commands.pm 1.2 KB

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