1
0

convenience.t 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. SKIP: {
  32. skip 'Can only test IE on windows', 1 unless $^O eq 'MSWin32';
  33. my $ie = Selenium::InternetExplorer->new( %caps );
  34. ok( $ie->browser_name eq 'internet_explorer', 'convenience ie is okay' );
  35. $ie->quit;
  36. }
  37. };
  38. subtest TestDriver => sub {
  39. my $phantomjs = Test::Selenium::PhantomJS->new( %caps );
  40. ok( $phantomjs->browser_name eq 'phantomjs', 'convenience phantomjs is okay' );
  41. $phantomjs->get_ok('about:config');
  42. $phantomjs->quit;
  43. my $firefox = Test::Selenium::Firefox->new( %caps );
  44. $firefox->get_ok('about:config');
  45. ok( $firefox->browser_name eq 'firefox', 'convenience firefox is okay' );
  46. $firefox->quit;
  47. my $chrome = Test::Selenium::Chrome->new( %caps );
  48. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  49. $chrome->get_ok('about:config');
  50. $chrome->quit;
  51. SKIP: {
  52. skip 'Can only test IE on windows', 1 unless $^O eq 'MSWin32';
  53. my $ie = Test::Selenium::InternetExplorer->new( %caps );
  54. ok( $ie->browser_name eq 'internet_explorer', 'convenience ie is okay' );
  55. $ie->quit;
  56. }
  57. };
  58. done_testing;