convenience.t 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. use strict;
  2. use warnings;
  3. use Selenium::Chrome;
  4. use Selenium::Firefox;
  5. use Selenium::InternetExplorer;
  6. use Selenium::PhantomJS;
  7. use Test::Selenium::Chrome;
  8. use Test::Selenium::Firefox;
  9. use Test::Selenium::InternetExplorer;
  10. use Test::Selenium::PhantomJS;
  11. use Test::More;
  12. use FindBin;
  13. use lib $FindBin::Bin . '/lib';
  14. use TestHarness;
  15. my $harness = TestHarness->new(
  16. this_file => $FindBin::Script
  17. );
  18. my %caps = %{ $harness->base_caps };
  19. $caps{remote_server_addr} = '127.0.0.1';
  20. delete $caps{browser_name};
  21. subtest Driver => sub {
  22. my $phantomjs = Selenium::PhantomJS->new( %caps );
  23. ok( $phantomjs->browser_name eq 'phantomjs', 'convenience phantomjs is okay' );
  24. $phantomjs->quit;
  25. my $firefox = Selenium::Firefox->new( %caps );
  26. ok( $firefox->browser_name eq 'firefox', 'convenience firefox is okay' );
  27. $firefox->quit;
  28. my $chrome = Selenium::Chrome->new( %caps );
  29. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  30. $chrome->quit;
  31. };
  32. subtest TestDriver => sub {
  33. my $phantomjs = Test::Selenium::PhantomJS->new( %caps );
  34. ok( $phantomjs->browser_name eq 'phantomjs', 'convenience phantomjs is okay' );
  35. $phantomjs->get_ok('about:config');
  36. $phantomjs->quit;
  37. my $firefox = Test::Selenium::Firefox->new( %caps );
  38. $firefox->get_ok('about:config');
  39. ok( $firefox->browser_name eq 'firefox', 'convenience firefox is okay' );
  40. $firefox->quit;
  41. my $chrome = Test::Selenium::Chrome->new( %caps );
  42. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  43. $chrome->get_ok('about:config');
  44. $chrome->quit;
  45. };
  46. done_testing;