1
0

Commands.pm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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}) && ($cmds->{$cmd}->{url} eq $params->{url})) {
  28. $method_name = $cmd;
  29. last;
  30. }
  31. }
  32. return $method_name;
  33. }
  34. 1;
  35. __END__
  36. =pod
  37. =head1 DESCRIPTION
  38. Utility class to be for testing purposes, with L<Selenium::Remote::Mock::RemoteConnection> only.
  39. =cut