11-action-chains.t 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. use strict;
  2. use warnings;
  3. use JSON;
  4. use Test::More;
  5. use Selenium::Remote::Driver;
  6. use Selenium::Remote::Mock::Commands;
  7. use Selenium::Remote::Mock::RemoteConnection;
  8. use Selenium::Remote::Driver::ActionChains;
  9. my $record = (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1))?1:0;
  10. my $os = $^O;
  11. if ($os =~ m/(aix|freebsd|openbsd|sunos|solaris)/) {
  12. $os = 'linux';
  13. }
  14. my %selenium_args = (
  15. browser_name => 'firefox'
  16. );
  17. my $mock_file = "11-action-chains-mock-$os.json";
  18. if (!$record && !(-e "t/mock-recordings/$mock_file")) {
  19. plan skip_all => "Mocking of tests is not been enabled for this platform";
  20. }
  21. if ($record) {
  22. $selenium_args{remote_conn} = Selenium::Remote::Mock::RemoteConnection->new(record => 1);
  23. }
  24. else {
  25. $selenium_args{remote_conn} =
  26. Selenium::Remote::Mock::RemoteConnection->new( replay => 1,
  27. replay_file => "t/mock-recordings/$mock_file" );
  28. }
  29. my $driver = Selenium::Remote::Driver->new(%selenium_args);
  30. my $action_chains = Selenium::Remote::Driver::ActionChains->new(driver => $driver);
  31. $driver->get('http://html5demos.com/drag');
  32. $driver->pause('1000');
  33. my $src = $driver->find_element('a#two', 'css');
  34. my $tgt = $driver->find_element('div#bin','css');
  35. $action_chains->drag_and_drop($src,$tgt)->perform();
  36. if ($record) {
  37. $driver->remote_conn->dump_session_store("t/mock-recordings/$mock_file");
  38. }
  39. done_testing;