12-reuse-session.t 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. use strict;
  2. use warnings;
  3. use Test::More;
  4. use Test::Selenium::Remote::Driver;
  5. use Selenium::Remote::Mock::RemoteConnection;
  6. use FindBin;
  7. use lib $FindBin::Bin . '/lib';
  8. use TestHarness;
  9. my $harness = TestHarness->new(
  10. this_file => $FindBin::Script
  11. );
  12. my @browsers = qw/chrome firefox/;
  13. foreach (@browsers) {
  14. my %selenium_args = (
  15. default_finder => 'css',
  16. javascript => 1,
  17. %{ $harness->base_caps },
  18. browser_name => $_,
  19. );
  20. my $s1 = Test::Selenium::Remote::Driver->new(
  21. %selenium_args
  22. );
  23. my $s2 = Test::Selenium::Remote::Driver->new(
  24. %selenium_args,
  25. auto_close => 0,
  26. session_id => $s1->session_id,
  27. );
  28. my $s3 = Test::Selenium::Remote::Driver->new(
  29. %selenium_args,
  30. );
  31. is($s1->session_id, $s2->session_id, "session_id is reused when specified");
  32. isnt($s1->session_id, $s3->session_id, "session_id not reused");
  33. pass("session_id.1=". $s2->session_id);
  34. pass("session_id.2=". $s2->session_id);
  35. pass("session_id.3=". $s3->session_id);
  36. my $perl_title = 'The Perl Programming Language - www.perl.org';
  37. my $cpan_title = 'The Comprehensive Perl Archive Network - www.cpan.org';
  38. $s1->get_ok('http://perl.org/');
  39. $s1->title_is($perl_title, 'perl.org title matches correctly');
  40. $s3->get_ok('http://perl.org/');
  41. $s3->title_is($perl_title, 'perl.org title matches correctly');
  42. }
  43. done_testing;