Test-Selenium-Remote-Driver-google.t 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use Test::More;
  5. use Test::Selenium::Remote::Driver;
  6. use Selenium::Remote::Mock::RemoteConnection;
  7. my $record = (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1))?1:0;
  8. my $os = $^O;
  9. if ($os =~ m/(aix|freebsd|openbsd|sunos|solaris)/) {
  10. $os = 'linux';
  11. }
  12. my %selenium_args = (
  13. browser_name => 'firefox',
  14. javascript => 1
  15. );
  16. my $mock_file = "test-selenium-remote-driver-google-$os.json";
  17. if (!$record && !(-e "t/mock-recordings/$mock_file")) {
  18. plan skip_all => "Mocking of tests is not been enabled for this platform";
  19. }
  20. if ($record) {
  21. $selenium_args{remote_conn} = Selenium::Remote::Mock::RemoteConnection->new(record => 1);
  22. }
  23. else {
  24. $selenium_args{remote_conn} =
  25. Selenium::Remote::Mock::RemoteConnection->new( replay => 1,
  26. replay_file => "t/mock-recordings/$mock_file" );
  27. }
  28. # Try to find
  29. my $t = Test::Selenium::Remote::Driver->new(
  30. %selenium_args
  31. );
  32. $t->get_ok('http://www.google.com');
  33. $t->title_like(qr/Google/);
  34. $t->body_like(qr/Google/);
  35. if ($record) {
  36. $t->remote_conn->dump_session_store("t/mock-recordings/$mock_file");
  37. }
  38. done_testing();