$form->{path} entfernt und hardcodiert auf bin/mozilla gesetzt.
[kivitendo-erp.git] / t / selenium / AllTests.t
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2006
4 # Web http://www.lx-office.org
5 #
6 #=====================================================================
7 #
8 #  Author: Udo Spallek
9 #   Email: udono@gmx.net
10 #
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #======================================================================
24
25 # Selenium Main Caller
26 # Call all Selenium scripts from here. To use Selenium tests in 
27 # Lx-Office you need to Install Selenium Remote Control. Take a look at 
28 # the README Document for further informatinons on installing Selenium 
29 # and testing Lx-Office and of course writing your own testcases.
30 #
31 #######################################################################
32   no strict;
33   push @INC, ['/t/selenium'];
34   use vars qw( $lxdebug $lxtest $sel );
35   use strict;
36   use Carp;
37
38   use Test::WWW::Selenium;
39   use Test::More;
40   use IO::Socket;
41
42   eval { require('t/lxtest.conf'); };
43   if ($@) {
44     diag("No test configuration found in t/lxtest.conf.\n
45     Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n");
46   exit 0;
47   };
48
49   sub server_is_running {
50     return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
51                                  PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
52                                 );
53   }
54   if (server_is_running) {
55     plan tests => 204; # Need to be cutomized
56   }
57   else {
58     plan skip_all => "No selenium server found! "
59                     ."Maybe you forgot to start it or "
60                     ."the preferences in t/lxtest.conf doesen't fit to your system";
61     exit 0;
62   }
63
64   diag('Pretests and initialisation');
65
66
67
68   $lxtest->{test_id} = time; # create individual ids by unixtime
69   $lxtest->{testuserlogin}   = $lxtest->{testlogin} . $lxtest->{test_id};
70   $lxtest->{testuserpasswd}  = $lxtest->{test_id};
71   $lxtest->{db}              = $lxtest->{db} . $lxtest->{test_id};
72
73   ok(defined $lxtest->{rpw}, "Get root password");
74   
75   ok(defined $lxtest->{dbhost}, "found dbhost in config");
76   ok(defined $lxtest->{dbport}, "found dbport in config");
77   ok(defined $lxtest->{dbuser}, "found dbuser in config");
78   ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config");
79
80   $lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
81
82
83
84
85
86   eval { $sel = Test::WWW::Selenium->new(
87     host => $lxtest->{seleniumhost},
88     port => $lxtest->{seleniumport},
89     browser => $lxtest->{seleniumbrowser},
90     browser_url => $lxtest->{lxadmin},
91     auto_stop => '0',
92     );
93   };
94   if ($@) {
95     diag("No Selenium Server running, or wrong preferences\n\n");
96     exit 0;
97   }
98
99   ok(defined $sel, 'Creating Selenium Object');
100
101   diag('Starting Selenium tests...');
102
103   opendir(SCRIPTS, 't/selenium/testscripts');
104   my @testscripts = sort readdir(SCRIPTS);
105   
106   foreach my $script (@testscripts){
107     my $file = "t/selenium/testscripts/" . $script;
108     require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ );
109   }
110   exit 1;
111
112   $sel=''; # Destroy selenium object
113
114   exit 1;
115