Commands.pm 964 B

1234567891011121314151617181920212223242526272829303132333435
  1. package Selenium::Remote::Mock::Commands;
  2. # ABSTRACT: utility class to mock Selenium::Remote::Commands
  3. use Moo;
  4. extends 'Selenium::Remote::Commands';
  5. # override get_params so we do not rewrite the parameters
  6. sub get_params {
  7. my $self = shift;
  8. my $args = shift;
  9. my $data = {};
  10. my $command = delete $args->{command};
  11. $data->{'url'} = $self->get_url($command);
  12. $data->{'method'} = $self->get_method($command);
  13. $data->{'no_content_success'} = $self->get_no_content_success($command);
  14. $data->{'url_params'} = $args;
  15. return $data;
  16. }
  17. sub get_method_name_from_parameters {
  18. my $self = shift;
  19. my $params = shift;
  20. my $method_name = '';
  21. my $cmds = $self->get_cmds();
  22. foreach my $cmd (keys %{$cmds}) {
  23. if (($cmds->{$cmd}->{method} eq $params->{method}) && ($cmds->{$cmd}->{url} eq $params->{url})) {
  24. $method_name = $cmd;
  25. last;
  26. }
  27. }
  28. return $method_name;
  29. }
  30. 1;