Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6d8b737a

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 6d8b737a2d442a9a50c8e02e8c1e5fc9dbf8eb88
  • Vorgänger 5fa26f9a
  • Nachfolger 1feda885

Alte Selennium-Tests löschen

Unterschiede anzeigen:

t/old/README
1
Directory for automated test scripts.
t/old/README.de
1
Lx-Office Testumgebung
2

  
3
Mit der hier beschriebenen Testumgebung ist es m?glich, Lx Office 
4
automatisiert zu testen. Automatische Tests haben den gro?en 
5
Vorteil, das verschiedene Standardtests nicht immer wieder von 
6
Hand durchgespielt werden m?ssen, sondern einmal in einem Skript 
7
verschriftet immer wieder verwendet werden k?nnen.
8
Weitere Informationen k?nnen im Wiki nachgelesen und erg?nzt werden:
9
http://wiki.lx-system.de/index.php/Automatisiertes_Testen_von_Modulen
10

  
11

  
12

  
13
Aufbau der Testumgebung
14
Im Verzeichnis t/ finden sich alle testrelevanten Skripte.Der 
15
Aufruf der Tests folgt ?ber 
16
#perl t/lx-office.t
17

  
18
lx-office.t ruft alle Einzeltests der Reihe nach auf und fasst sie
19
?bersichtlich zusammen. Die Einzeltests befinden sich in einem 
20
Unterordner von t/. Jeder Unterorder enth?lt eine Datei AllTests.t, 
21
die wiederrum alle einzelnen Tests des Unterordners aufruft.
22

  
23

  
24

  
25
t/lxtest.conf t/lxtest.conf.default
26
F?r die einzelnen Tests werden verschiedene Packetvariablen (globals) 
27
zur Verf?gung gestellt, um die Testskripte einfach auf 
28
unterschiedliche Installationen anpassen zu k?nnen und um sich auf 
29
die selbe Test-Datenbank und denselben Test-Benutzer beziehen zu k?nnen.
30

  
31
Die Datei t/lxtest.conf.default muss zun?chst nach t/lxtest.conf 
32
kopiert werden. Dann ist die Datei t/lxtest.conf auf die lokalen
33
Gegebenheiten anzupassen. Besnders die f?r Selenium n?tigen 
34
Einstellungen bed?rfen einer ?berarbeitung.
35

  
36
Definiert werden die Variablen in der Datei t/lxtest.conf.
37
Aufgerufen werden die Variablen $lxtest->{VARIABLE}.
38
Es ist ratsam, die vorhandenen Tests zu untersuchen, um sich ein Bild 
39
von den M?glichkeiten zu machen.
40

  
41

  
42

  
43
Selenium
44
Selenium ist eine Testsuite, mit der man Browserinteraktionen 
45
simulieren und die Ergebnisse auswerten kann. Der unschlagbare 
46
Vorteil von Selenium f?r das Testen von Lx ist es, dass es 
47
m?glich wird, eine Test-Datenbank in einfachen Schritten 
48
erstellen zu k?nnen. Um Seleniumtests durchf?hren zu k?nnen, 
49
ist es n?tig, das Packet Selenium Remote Control (Selenium RC) 
50
lokal zu installieren (Java Runtime ebenfalls erforderlich). 
51
Selenium RC gibt es unter:
52
http://www.openqa.org/selenium-rc/
53

  
54
F?r den Betrieb von Selenium ist eine lokale Workstation mit 
55
Browserumgebung n?tig.
56

  
57
Der Aufruf von selenium erfolgt unter Windows bspw. so:
58
C:\java -jar "C:\selenium-remote-control-0.9.0
59
\server\selenium-server.jar"
60

  
61
Unter Linux bspw. so:
62
<FIXME>
63

  
64
Die lokalen Einstellungen sind unbedingt in der 
65
t/lxtest.conf nachzutragen! Weitere Infos unter
66
http://www.openqa.org/selenium-rc/
67

  
68
Dann reicht ein Start von 
69
#perl t/lx-office.t
70
um dem Testskript bei der Arbeit zuzuschauen.
71

  
72
Leider ist es n?tig, auf dem Seleniumserver nach jedem Aufruf
73
des Testskripts das Sicherheitszertifikat von LINET Services zu 
74
akzeptieren, was etwas nervig ist.
75

  
76

  
77
t/selenium/
78
Der Ordner selenium beinhaltet alle einzelnen selenium Testskripte.
79
Aufgerufen werden die Skripte ?ber t/selenium/AllTests.t .
80
Neue Tests m?ssen in dieser Datei angemeldet werden.
81
Ziel ist es eine Demodatenbank von Lx mit Daten zu f?llen und die 
82
Abh?ngigkeiten untereinander zu pr?fen. Dazu sind die 
83
individuellen Testskripte nummeriert (001NAME.t bis 999NAME.t) um 
84
sie der Reihe nach abzuarbeiten.
85

  
86
Die folgenden Skripte sind bereits installiert:
87

  
88
001CreateTestDatabase.t  Erzeugt eine neue Testdatenbank
89
002CreateTestUser.t      Erzeugt einen neuen Testbenutzer
90
...
91
...
92
998DeleteTestUser.t      L?scht den Testbenutzer
93
999DeleteTestDatabase.t  L?scht die Testdatenbank
94

  
95
Dazwischen befinden sich die Skripte, um eine Demodatenbank 
96
aufzubauen und zu pr?fen.
97

  
98

  
99

  
100
t/backend/
101
In diesem Ordner befinden sich Backend Testskripte.
102

  
103

  
104

  
105
t/frontend/
106
In diesem Ordner befinden sich Frontend Testskripte, die nicht 
107
unter selenium getestet werden.
108

  
109

  
110

  
111
Was wenn ein Test fehlschl?gt?
112
Das Fehlschlagen von Tests kann verschiedene Gr?nde haben.
113
1. Der Test selbst ist fehlerhaft.
114
2. Es haben sich Lx Screens ver?ndert, so das der Test von 
115
   falschen Voraussetzungen ausgeht
116
3. Die zu testende Funktion ist fehlerhaft
117

  
118
Nachdem 1. und 2.  ausgeschlossen wurden, sollte zu 3. ein Bugreport 
119
angelegt werden. 
120
Bugreports unter https://lx-office.linet-services.de/bugzilla/
121
anlegen.
122

  
123

  
124

  
125
Eigene Tests
126
Eigene testskripte k?nnen einfach in die Testumgebung eingebunden 
127
werden. Die vorhandenen Skripte k?nnen als Anleitung dienen. 
128
Bei Selenium Tests ist es am leichtesten, mit Firefox und der 
129
Selenium IDE Extension Testpfade einfach aufzuzeichnen.
130
( http://www.openqa.org/selenium-ide/ )
131
Dann werden die Selenium IDE Testaufzeichnungen in Perl 
132
umgewandelt und angepasst. Fertige Skripte werden mit einer 
133
laufenden Nummer versehen und in den Ordner t/selenium/ kopiert.
134
Dann wird das Skript in der Datei t/selenium/AllTests.t eingef?gt.
135
Ein erster Probelauf mit 
136
#perl t/selenium/AllTests.t sollte den Test absolvieren.
137
(Dabei kann es n?tig sein, andere Tests auszukommentieren, weil 
138
selenium Tests mitunter lange Laufzeiten haben k?nnen, oder weil die Demodatenbank 
139
und der Benutzer am Ende zu Debugging Zwecken nicht gel?scht werden
140
sollen.)
141

  
142

  
t/old/backend/README.backend
1
This folder contais the backend testscrips for Lx.
2
The Lx backend is the module libery under SL.
3
Backend tests don't need selenium, and are only able
4
to test local installations.
t/old/demolx/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

  
t/old/demolx/README
1
This directory contains all selenium testscripts for lx-office.
2
Selenium testscrips are the prefered way to test the higher lx 
3
functionalities. For the selenium tests you need to install and
4
run a local selenium server on a machine whitch is able to start 
5
a browser session. See README for more informations.
6

  
7

  
t/old/demolx/cleanup.pl
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 Cleanup Script
26
# To clean up all the messy databases and users while debugging testcases
27
# 
28
#######################################################################
29
  no strict;
30
  push @INC, ['/t/selenium'];
31
  use vars qw( $lxdebug $lxtest $sel );
32
  use strict;
33
  use Carp;
34

  
35
  use WWW::Selenium;
36
  use IO::Socket;
37

  
38
  my $cleanedupdb = '';
39
  my $cleanedupusers = '';
40

  
41
  eval { require('t/lxtest.conf'); };
42
  if ($@) {
43
    print "No test configuration found in t/lxtest.conf.\n
44
    Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n";
45
  exit 0;
46
  };
47

  
48
  sub server_is_running {
49
    return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
50
                                 PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
51
                                );
52
  }
53
  if (server_is_running) {
54
  }
55
  else {
56
    exit 0;
57
  }
58

  
59
  $lxtest->{testuserlogin}   = $lxtest->{testlogin};
60
  $lxtest->{db}              = $lxtest->{db};
61

  
62
  $lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
63

  
64
  eval { $sel = WWW::Selenium->new(
65
    host => $lxtest->{seleniumhost},
66
    port => $lxtest->{seleniumport},
67
    browser => $lxtest->{seleniumbrowser},
68
    browser_url => $lxtest->{lxadmin},
69
    auto_stop => '0',
70
    );
71
  };
72
  if ($@) {
73
    print "No Selenium Server running, or wrong preferences\n\n";
74
    exit 0;
75
  }
76

  
77

  
78
  print "\nStarting Testdebugging Cleanup...\n";
79

  
80

  
81
### Delete user
82

  
83
$sel->start;
84
print "Cleanup all users '$lxtest->{testuserlogin}*'\n";
85
$sel->open($lxtest->{lxadmin});
86

  
87
my @links= $sel->get_all_links();
88
my $testuserlogin = $lxtest->{testuserlogin};
89

  
90
foreach my $link (@links) {
91

  
92
  if ($link =~ /$testuserlogin\d\d\d\d\d\d\d\d\d\d/){
93
    $sel->click("link=$lxtest->{testuserlogin}11*");
94
    $sel->wait_for_page_to_load($lxtest->{timeout});
95
    $sel->click("//input[(\@name=\"action\") and (\@value=\"L?schen\")]");
96
    $sel->wait_for_page_to_load($lxtest->{timeout});
97
    $cleanedupusers .= "     $link\n";
98
  }
99
}
100

  
101
print "Lock the system\n";
102
$sel->click("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
103
$sel->wait_for_page_to_load($lxtest->{timeout});
104

  
105
print "Cleanup all test databasees: '$lxtest->{db}*'\n";
106

  
107
  $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
108
  $sel->wait_for_page_to_load($lxtest->{timeout});
109
  $sel->type("dbhost", $lxtest->{dbhost});
110
  $sel->type("dbport", $lxtest->{dbport});
111
  $sel->type("dbuser", $lxtest->{dbuser});
112
  $sel->type("dbpasswd", $lxtest->{dbpasswd});
113
 
114
  $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
115
  $sel->wait_for_page_to_load($lxtest->{timeoutlong});
116

  
117
  my $field = $sel->get_body_text();
118
  my $database= $lxtest->{db};
119
  my @fields = split('  ', $field);
120

  
121
  
122
  foreach my $field (@fields) {
123

  
124
    if ($field =~ /$database\d\d\d\d\d\d\d\d\d\d/){
125
      $sel->open($lxtest->{lxadmin});
126
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
127
      $sel->wait_for_page_to_load($lxtest->{timeout});
128
      $sel->type("dbhost", $lxtest->{dbhost});
129
      $sel->type("dbport", $lxtest->{dbport});
130
      $sel->type("dbuser", $lxtest->{dbuser});
131
      $sel->type("dbpasswd", $lxtest->{dbpasswd});
132
     
133
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
134
      $sel->wait_for_page_to_load($lxtest->{timeoutlong});
135
      $sel->check("name=db value=$field"); 
136
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
137
      $cleanedupdb .= "     $field\n";
138
      
139
    }
140
  }
141
  
142
$sel->open($lxtest->{lxadmin});
143
print "Unlock the system\n";
144

  
145
$sel->click("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
146
$sel->wait_for_page_to_load($lxtest->{timeout});
147

  
148
$cleanedupdb = "none.\n" if ($cleanedupdb eq '');
149
$cleanedupusers = "none.\n" if ($cleanedupusers eq '');
150

  
151
print "Ready. \nReport:\n--- Cleaned up Users:\n$cleanedupusers---Cleaned up Databases:\n$cleanedupdb";
152

  
153
$sel->stop;
154

  
155
exit 1;
156

  
157

  
t/old/demolx/testscripts/001CreateTestDatabase.t
1
### Create Database
2

  
3
$sel->open_ok($lxtest->{lxadmin});
4
$sel->title_is("Lx-Office ERP Administration -");
5

  
6
diag('Lock the system');
7
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
8
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
9

  
10
diag("Create test database '$lxtest->{db}'");
11
$sel->title_is("Lx-Office ERP Administration -");
12
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
13
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
14
$sel->title_is("Lx-Office ERP / Datenbankadministration -");
15
$sel->type_ok("dbuser", $lxtest->{dbuser});
16
$sel->type_ok("dbpasswd", $lxtest->{dbpasswd});
17
$sel->type_ok("dbuser", $lxtest->{dbuser});
18
$sel->type_ok("dbhost", $lxtest->{dbhost});
19
$sel->type_ok("dbport", $lxtest->{dbport});
20
$sel->type_ok("dbdefault", $lxtest->{dbdefault});
21
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank anlegen\")]");
22
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
23
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -");
24
$sel->type_ok("db", $lxtest->{db});
25
$sel->select_ok("encoding", "label=ISO 8859-1");
26
$sel->click_ok("//input[(\@name=\"chart\") and (\@value=\"Germany-DATEV-SKR03EU\")]");
27
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
28
$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong});
29
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -");
30
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
31
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
32
$sel->title_is("Lx-Office ERP Administration -");
33

  
34
diag('Unlock the system');
35
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
36
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
37
$sel->title_is("Lx-Office ERP Administration -");
t/old/demolx/testscripts/002CreateTestUser.t
1

  
2
### Create new user
3
diag("Create test user '$lxtest->{testuserlogin}'");
4
$sel->open_ok($lxtest->{lxadmin});
5
$sel->title_is("Lx-Office ERP Administration -");
6
$sel->click_ok("action");
7
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
8
$sel->title_is("Lx-Office ERP Administration / Benutzer erfassen -");
9
$sel->type_ok("login", $lxtest->{testuserlogin});
10
$sel->type_ok("password", $lxtest->{testuserpasswd});
11
$sel->type_ok("name", "Selenium");
12
$sel->type_ok("email", "selenium\@lx-office.org");
13
$sel->type_ok("signature", "Selenium Testuser");
14
$sel->type_ok("tel", "0000");
15
$sel->type_ok("fax", "1111");
16
$sel->type_ok("company", "Sel-enium");
17
$sel->type_ok("signature", "Selenium Testuser\nTestfirma");
18
$sel->type_ok("address", "Testfirma");
19
$sel->type_ok("steuernummer", "111-222-333-444");
20
$sel->type_ok("co_ustid", "1234567");
21
$sel->type_ok("duns", "0987654321");
22
$sel->click_ok("dbdriver");
23
$sel->type_ok("newtemplates", "seleniumtestuser");
24
$sel->click_ok("menustyle");
25
$sel->type_ok("Pg_dbhost", $lxtest->{dbhost});
26
$sel->type_ok("Pg_dbname", $lxtest->{db});
27
$sel->type_ok("Pg_dbport", $lxtest->{dbport});
28
$sel->type_ok("Pg_dbuser", $lxtest->{dbuser});
29
$sel->type_ok("Pg_dbpasswd", $lxtest->{dbpasswd});
30
$sel->click_ok("action");
31
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
32
$sel->title_is("Lx-Office ERP Administration -");
t/old/demolx/testscripts/005UpdateDatabase.t
1
### Update Database
2

  
3
# NOTEST: some preruns for initializing missing parameters
4
$sel->open($lxtest->{lxadmin});
5
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
6
$sel->wait_for_page_to_load($lxtest->{timeout});
7
$sel->type("dbuser", $lxtest->{dbuser});
8
$sel->type("dbpasswd", $lxtest->{dbpasswd});
9
$sel->type("dbuser", $lxtest->{dbuser});
10
$sel->type("dbhost", $lxtest->{dbhost});
11
$sel->type("dbport", $lxtest->{dbport});
12
$sel->type("dbdefault", $lxtest->{dbdefault});
13
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank aktualisieren\")]");
14
$sel->wait_for_page_to_load($lxtest->{timeoutlong});
15
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank aktualisieren -");
16

  
17
my $count =0;
18

  
19
while (){ # count the number of radiobuttons
20
  eval {  $sel->is_checked("//input[(\@id=\"$count\")]"); };
21
    if ( $@ ) { $count--; last; }; 
22
  $count++;
23
}
24

  
25
#TEST: Now run the Tests
26

  
27
$sel->open_ok($lxtest->{lxadmin});
28
$sel->title_is("Lx-Office ERP Administration -");
29

  
30
#diag('Lock the system');
31
#$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
32
#$sel->wait_for_page_to_load_ok($lxtest->{timeout});
33

  
34
diag('Update the database');
35

  
36
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
37
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
38
$sel->title_is("Lx-Office ERP / Datenbankadministration -");
39
$sel->type_ok("dbuser", $lxtest->{dbuser});
40
$sel->type_ok("dbpasswd", $lxtest->{dbpasswd});
41
$sel->type_ok("dbuser", $lxtest->{dbuser});
42
$sel->type_ok("dbhost", $lxtest->{dbhost});
43
$sel->type_ok("dbport", $lxtest->{dbport});
44
$sel->type_ok("dbdefault", $lxtest->{dbdefault});
45
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank aktualisieren\")]");
46
$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong});
47
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank aktualisieren -");
48

  
49
for (my $i=0; $i <= $count; $i++){
50
  $sel->uncheck_ok("//input[(\@id=\"$i\")]");
51
}
52

  
53
#$sel->click_ok("//input[\@value=\"$lxtest->{db}\"]");
54
$sel->check_ok("//input[\@name=\"db$lxtest->{db}\"]");
55
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
56
$sel->title_like( qr/Lx-Office ERP Datenbankadministration/ );
57

  
58
#diag('Unlock the system');
59
#$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
60
#$sel->wait_for_page_to_load_ok($lxtest->{timeout});
61
#$sel->title_is("Lx-Office ERP Administration -");
62

  
t/old/demolx/testscripts/K998DeleteTestUser.t
1
### Delete user
2
diag("Delete test user '$lxtest->{testuserlogin}'");
3
$sel->open_ok($lxtest->{lxadmin});
4
$sel->title_is("Lx-Office ERP Administration -");
5
$sel->click_ok("link=$lxtest->{testuserlogin}");
6
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
7
$sel->title_is("Lx-Office ERP Administration / Benutzerdaten bearbeiten -");
8
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"L?schen\")]");
9
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
t/old/demolx/testscripts/K999DeleteTestDatabase.t
1
#### Delete database
2

  
3

  
4
$sel->open_ok($lxtest->{lxadmin});
5
$sel->title_is("Lx-Office ERP Administration -");
6

  
7
diag('Lock the system');
8
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
9
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
10

  
11
diag("Delete test database '$lxtest->{db}'");
12
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
13
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
14
$sel->title_is("Lx-Office ERP / Datenbankadministration -");
15
$sel->type_ok("dbhost", $lxtest->{dbhost});
16
$sel->type_ok("dbport", $lxtest->{dbport});
17
$sel->type_ok("dbuser", $lxtest->{dbuser});
18
$sel->type_ok("dbpasswd", $lxtest->{dbpasswd});
19
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
20
$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong});
21
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank l?schen -");
22

  
23
$sel->click_ok("//input[\@value=\"$lxtest->{db}\"]");
24

  
25
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
26
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
27
$sel->body_text_is("Lx-Office ERP Datenbankadministration / Datenbank l?schen $lxtest->{db} wurde erfolgreich gel?scht");
28
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
29
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
30
$sel->title_is("Lx-Office ERP Administration -");
31

  
32
diag('Unlock the system');
33
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
34
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
35
$sel->title_is("Lx-Office ERP Administration -");
t/old/demolx/testscripts/README
1
All Selenium testscripts can be found here. The tests will be included
2
sequential from 001 to 999.
t/old/frontend/README.frontend
1
This folder contais the frontend testscrips for Lx.
2
The Lx frontend are all perl scripts under bin/* .
3
The frontend tests don't need selenium! They should 
4
use the commandline API of Lx. Frontend tests in this 
5
directory are only for testing local Lx installations.
6

  
7
If you like to test the HTML screens in different 
8
Browsers, it would be better to use the selenium 
9
environment under t/selenium.
10

  
t/old/lx-office.t
1
#=====================================================================
2
# LX-Office ERP
3
# Copyright (C) 2006/2007
4
# Web http://www.lx-office.org
5
#
6
#=====================================================================
7
#
8
#  Author: Udo Spallek, Thomas Kasulke
9
#   Email: udono@gmx.net, tkasulke@linet-services.de
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
# Main Test Module: 
26
# For collecting all the tests in nice Test::Harness environment.
27
# Study the README for Selenium Installation and testing process 
28
# and enjoy starting
29
# #perl t/lx-office.t
30
# against the unstable release
31
#======================================================================
32

  
33
  use warnings FATAL => 'all';
34
  use diagnostics;
35
  use Carp;
36
  use Test::Harness;
37
  
38
  my %tests = ("all" => 't/selenium/TestAllTests.t',
39
               "system" => 't/selenium/TestSystem.t',
40
               "selling" => 't/selenium/TestSelling.t',
41
               "masterdata" => 't/selenium/TestMasterData.t',
42
               "testbed" => 't/selenium/TestCreateTestbed.t',
43
               "admin" => 't/selenium/TestAdmin.t',
44
               "accounting" => 't/selenium/TestAccounting.t',
45
               "payments" => 't/selenium/TestPayments.t',
46
               "printing" => 't/selenium/TestPrinting.t',
47
               "programm" => 't/selenium/TestProgramm.t',
48
               "reports" => 't/selenium/TestReports.t' );
49
  my $showtests = 0;
50
  my $singletest = 0;
51
  my $nodb = 0;
52
  my @totest;
53
  
54
  eval { require('t/lxtest.conf'); };
55
  my %lxtest = %{ $lxtest } if ($lxtest);
56

  
57
  sub usage
58
  {
59
    print "\n$0 --- creates testscenarios while using Selenium testcases for Lx-Office\n";
60
    printf "\t\tusage: perl [PERLOPTIONS] $0 [--help] [OPTIONS] [ARGUMENTS]\n\t\t%s\n", "\xAF" x 6;
61
    print "\t\t --help\t\tshow this usage\n\n";
62
    printf "\t\toptions:\n\t\t%s\n", "\xAF" x 8;
63
    print "\t\t  -masterdata\tonly runs testscripts for \"masterdata\"\n";
64
    print "\t\t  -accounting\tonly runs testscripts for \"accounting\"\n";
65
    print "\t\t  -system\tonly runs testscripts for \"system\"\n";
66
    print "\t\t  -payments\tonly runs testscripts for \"payments\"\n";
67
    print "\t\t  -programm\tonly runs testscripts for \"programm\"\n";
68
    print "\t\t  -printing\tonly runs testscripts for \"printing\"\n";
69
    print "\t\t  -reports\tonly runs testscripts for \"reports\"\n";
70
    print "\t\t  -selling\tonly runs testscripts for \"selling\"\n";
71
    print "\t\t  -purchase\tonly runs testscripts for \"purchase\"\n";
72
    print "\t\t  -admin\tonly runs testscripts for \"administration\"\n";
73
    print "\t\t  -testbed\tcreates a standardized test database\n";
74
    print "\t\t  -nodb\t\tdoesn't create a db! Only use with \n\t\t\t\t--username, --userpasswd, --dbname, --dbport, --dbhost, --dbuser, --dbpasswd, --rootpasswd arguments!\n";
75
    print "\t\t  -showtests\tfinally shows all tests available only\n";
76
    print "\t\t  -singletest\toption flag for using single tests shown in \"-showtests\"\n";
77
    printf "\n\t\targuments:\n\t\t%s\n","\xAF" x 10;
78
    print "\t\t  --test=\tname of Test shown in showtests seperated by , (Only joined by -singletest)\n";
79
    print "\t\t  --username=\tuser login name\n";
80
    print "\t\t  --userpasswd=\tuser login password\n";
81
    print "\t\t  --dbname=\tname of used db (leave empty whether dbname is seleniumtestdatabase)\n";
82
    print "\t\t  --dbport=\tport of used db (leave empty whether port is 5432)\n";
83
    print "\t\t  --dbhost=\thost of used db (leave empty whether host is localhost [127.0.0.1])\n";
84
    print "\t\t  --dbuser=\tdb username (leave empty whether name is postgres)\n";
85
    print "\t\t  --dbpasswd=\tthe password for used db (leave empty while none)\n";
86
    print "\t\t  --rootpasswd=\troot password for admin.pl login\n";
87
    printf "\t\t  NOTE: Configuration in lxtest.conf will be temporaly overwritten by using this arguments!\n\t\t %s\n", "\xAF" x 6;
88
    exit;
89
  }
90
  
91
  while ( $#ARGV>=0 )
92
  {
93
    $_ = $ARGV[0];
94

  
95
    if ( /^--help$/ ) { usage; last }
96
    elsif ( /^-showtests$/) { $showtests = 1; shift; next }
97
    elsif ( /^-nodb$/ ) { $nodb = 1; shift; next }
98
    elsif ( /^-(masterdata)$/ ) { push @totest, $1; shift; next }
99
    elsif ( /^-(system)$/ ) { push @totest, $1; shift; next }
100
    elsif ( /^-(selling)$/ ) { push @totest, $1; shift; next }
101
    elsif ( /^-(purchase)$/ ) { push @totest, $1; shift; next }
102
    elsif ( /^-(testbed)$/ ) { push @totest, $1; shift; next }
103
    elsif ( /^-(payments)$/ ) { push @totest, $1; shift; next }
104
    elsif ( /^-(admin)$/ ) { push @totest, $1; shift; next }
105
    elsif ( /^-(printing)$/ ) { push @totest, $1; shift; next }
106
    elsif ( /^-(reports)$/ ) { push @totest, $1; shift; next }
107
    elsif ( /^-(accounting)$/ ) { push @totest, $1; shift; next }
108
    elsif ( /^-(purchase)$/ ) { push @totest, $1; shift; next }
109
    elsif ( /^-(programm)$/ ) { push @totest, $1; shift; next }
110
    elsif ( /^-singletest$/ ) { $singletest = 1; shift; next }
111
    elsif ( /^--username=(.*)$/ ) { $lxtest{testuserlogin} = $1; shift; next }
112
    elsif ( /^--userpasswd=(.*)$/ ) { $lxtest{testuserpasswd} = $1; shift; next }
113
    elsif ( /^--dbname=(.*)$/ ) { $lxtest{db} = $1; shift; next }
114
    elsif ( /^--dbport=(.*)$/ ) { $lxtest{dbport} = $1; shift; next }
115
    elsif ( /^--dbhost=(.*)$/ ) { $lxtest{dbhost} = $1; shift; next }
116
    elsif ( /^--dbuser=(.*)$/ ) { $lxtest{dbuser} = $1; shift; next }
117
    elsif ( /^--dbpasswd=(.*)$/ ) { $lxtest{dbpasswd} = $1; shift; next }
118
    elsif ( /^--rootpasswd=(.*)$/ ) { $lxtest{rpw} = $1; shift; next }
119
    elsif ( /^--test=(.*)$/ ) { foreach (split(/\,/, $1)) { push @totest, $_; } shift; next }
120
    elsif ( /^([A-Z].*)$/ ) { push @totest, shift; next }
121
    else {
122
        print STDERR "$0: ERROR: unrecognized option '$_' ?\n";
123
        usage;
124
    }
125
    last;
126
  }
127
  unlink("/tmp/lxtest-temp.conf") if (-f "/tmp/lxtest-temp.conf");
128
  open TEMPCONF, "+>/tmp/lxtest-temp.conf";
129
  print TEMPCONF '$lxtest = {'."\n";
130
  foreach (keys(%lxtest)) {
131
    print TEMPCONF '"' . $_ . '" => "' . $lxtest{$_} . "\",\n";
132
  }
133
  print TEMPCONF '};';
134
  close TEMPCONF;
135
  
136
  if($singletest || $showtests) {
137
    my $testscriptdir = 't/selenium/testscripts/';
138
    opendir(ROOT, $testscriptdir);
139
    foreach my $dir ( readdir( ROOT ) ) {
140
      if(-d $testscriptdir . $dir && $dir ne "begin" && $dir ne "end" && $dir ne "..") {
141
        opendir(DIR, $testscriptdir . $dir . "/begin");
142
        foreach ( readdir(DIR) ) {
143
          $tests{ substr ( substr( $_, 4 ), 0, -2 ) } = $testscriptdir . ($dir eq "." ? "" : $dir . "/") . "begin/" . $_ if ( $_ =~ /^\w\d\d\d.*\.t$/ );
144
        }
145
        closedir(DIR);
146
        opendir(DIR, $testscriptdir . $dir . "/end");
147
        foreach (readdir(DIR)) {
148
          $tests{ substr ( substr( $_, 4 ), 0, -2 ) } = $testscriptdir . ($dir eq "." ? "" : $dir . "/") . "end/" . $_ if ( $_ =~ /^\w\d\d\d.*\.t$/ );
149
        }
150
        closedir(DIR);
151
      }
152
    }
153
    closedir(ROOT);
154
  }
155
  push @totest, "all" if(!$totest[0]);
156
  
157

  
158
## Backendtests:
159
#  &runtests(
160
#  );  
161
  
162

  
163
## Frontendtests:
164
  if (!$showtests) {
165
    foreach (@totest) {
166
      &runtests(
167
        $tests{$_},
168
     );
169
    }
170
  }
171
  elsif($showtests) {
172
    printf "\tFollowing testscripts are present:\n\t%s\n","\xAF" x 34;;
173
    foreach (sort(keys(%tests))) {
174
      print "\t\t" . $_ ."\n" if( /^[A-Z].*$/ );
175
    }
176
    printf "\n\t\%s\n\t%s\n","Be ensure, that usage is promitted by login and db status!","\xAF" x 58;
177
  }
178
unlink("/tmp/lxtest-temp.conf");
179

  
180

  
181
exit 1;
t/old/lxtest.conf.default
1
# This is the main configuration file for testing Lx-Office. 
2
# The file t/lxtest.conf.default contains the configuration for
3
# testing the unstable trunk in the internet repository on
4
# https://lx-office.linet-services.de/svn-installationen/unstable/
5
# Simply copy the file
6
# t/lxtest.conf.default to t/lxtest.conf
7
# If you like to test the unstable trunk of the repository, start 
8
# perl t/lx-office.t .
9
# If you like to test your own Lx installation, customize the file
10
# t/lx-office.t for your own.
11
# Btw. a running Selenium server is required for testing Lx!
12
# See README for more informations.
13

  
14
$lxtest = {
15

  
16
    # Lx location and user configuration:
17
    # Please edit the following lines 
18
    # for testing a local installation
19

  
20
    lxbaseurl       => 'https://lx-office.linet-services.de/svn-installationen/unstable/',
21
    rpw             => 'ro26F.eQBldoA', # root passwordhash! is only
22
                       # neccessary if you test a remote instalation
23
    testlogin       => 'seleniumtestuser',# will be extended with unix time
24

  
25
    
26
    # Testdatabase configuration:
27
    # Please edit the following lines
28
    # for testing a local installation
29
    # ATTENTION: Testdatabase will be deleted after testrun!
30
    db              => 'seleniumtestdatabase',
31
    dbhost          => 'localhost',
32
    dbport          => '5432',
33
    dbuser          => 'postgres',
34
    dbpasswd        => '',
35
    dbdefault       => 'template1',
36

  
37
    # Selenium preferences:
38
    # Edit the selenium preferences for your system. 
39
    # A running Selenium server is required for testing Lx! 
40
    # See README for more informations.
41
    seleniumhost    => '192.168.1.10', # edit host of running selenium server
42
    seleniumbrowser => '*chrome C:\Programme\Mozilla Firefox\firefox.exe', # edit the path
43

  
44
    seleniumport    => '4444',
45
    timeout         => '30000',  #timeout for waiting Page load in ms
46
    timeoutlong     => '60000',  #timeout for waiting longer Page load in ms....
47

  
48

  
49
    #Lx defaults (usualy no need for editing)
50
    rootlogin       => "root login",
51
    memberfile      => "users/members",
52

  
53
    # Put your own setting for individual tests after here...
54

  
55
};
t/old/selenium/AllTests.t
1
#=====================================================================
2
# LX-Office ERP
3
# Copyright (C) 2006/2007
4
# Web http://www.lx-office.org
5
#
6
#=====================================================================
7
#
8
#  Author: Udo Spallek, Thomas Kasulke
9
#   Email: udono@gmx.net, tkasulke@linet-services.de
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', \&init_server];
34
  use vars qw( $lxdebug $lxtest $sel );
35
  use strict;
36
  use Carp;
37

  
38
  use Test::WWW::Selenium;
39
  use Test::More qw(no_plan);
40
  use IO::Socket;
41

  
42
  if(-f "/tmp/lxtest-temp.conf") {
43
    eval { require('/tmp/lxtest-temp.conf'); };
44
  }
45
  else {
46
    eval { require('t/lxtest.conf'); };
47
  }
48
  if ($@) {
49
    diag("No test configuration found in t/lxtest.conf.\n
50
    Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n");
51
  exit 0;
52
  }
53

  
54
  sub server_is_running {
55
    return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
56
                                 PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
57
                                );
58
  }
59
  
60
#   if (server_is_running) {
61
#     plan tests => 200; # Need to be cutomized
62
#   }
63
  sub init_server {
64
    my $singlefileonly = 0;
65
    if ($_[0] eq "singlefileonly") {  
66
      $singlefileonly = 1;
67
      shift;
68
    }
69
    if(!server_is_running) {
70
      print "No selenium server found! "
71
           ."Maybe you forgot to start it or "
72
           ."the preferences in t/lxtest.conf doesen't fit to your system";
73
      exit 0;
74
    }
75

  
76
    diag('Pretests and initialisation');
77

  
78

  
79

  
80
    $lxtest->{test_id} = time; # create individual ids by unixtime
81
    $lxtest->{testuserlogin}   = $lxtest->{testlogin} . $lxtest->{test_id} if(!$lxtest->{testuserlogin});
82
    $lxtest->{testuserpasswd}  = $lxtest->{test_id} if(!$lxtest->{testuserpasswd});
83
    $lxtest->{db}              = $lxtest->{db} . $lxtest->{test_id} if(!($lxtest->{db} =~ /^seleniumtestdatabase[0-9]{10}$/));
84

  
85
    ok(defined $lxtest->{rpw}, "Get root password");
86
  
87
    ok(defined $lxtest->{dbhost}, "found dbhost in config");
88
    ok(defined $lxtest->{dbport}, "found dbport in config");
89
    ok(defined $lxtest->{dbuser}, "found dbuser in config");
90
    ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config");
91

  
92
    $lxtest->{lxadmin_url} = $lxtest->{lxbaseurl} . "admin.pl";
93
    $lxtest->{lxadmin_with_get} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
94
    $lxtest->{lxadmin} = $lxtest->{lxadmin_url} . "?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
95

  
96

  
97

  
98

  
99
    eval { $sel = Test::WWW::Selenium->new(
100
      host => $lxtest->{seleniumhost},
101
      port => $lxtest->{seleniumport},
102
      browser => $lxtest->{seleniumbrowser},
103
      browser_url => $lxtest->{lxadmin},
104
      auto_stop => '0',
105
      );
106
    };
107
    if ($@) {
108
      diag("No Selenium Server running, or wrong preferences\n\n");
109
      exit 0;
110
    }
111
    
112
    ok(defined $sel, 'Creating Selenium Object');
113

  
114
    diag('Starting Selenium tests...');
115
    
116
    if(!$singlefileonly) {
117
      foreach my $scriptdir (@_) {
118
        opendir(SCRIPTS, 't/selenium/testscripts/' . $scriptdir) or die "Can't open directory!" . $!;
119
        foreach (sort readdir(SCRIPTS)) {
120
          if ( $_ =~ /^\w\d\d\d.*\.t$|^\d\d\d.*\.t$/  && !$sel->{ran_tests}{"t/selenium/testscripts/". $scriptdir . "/" . $_}) {
121
            require_ok("t/selenium/testscripts/". $scriptdir . "/" . $_);
122
            $sel->{ran_tests}{"t/selenium/testscripts/". $scriptdir . "/" . $_} = 1;
123
          }
124
        }
125
        closedir(SCRIPTS);
126
      }
127
    }
128
    else {
129
      foreach (@_) { 
130
        if ( $_ =~ /^.*\/\w\d\d\d.*\.t$|^.*\/\d\d\d.*\.t$/  && !$sel->{ran_tests}{$_}) {
131
          require_ok($_); 
132
          $sel->{ran_tests}{$_} = 1;
133
        }
134
      }
135
    }
136
    if($!) {
137
      @! = ("Test fehlgeschlagen!");
138
    }
139
    $sel->stop();
140
  }
141
  
142
  sub start_login() {
143
    require "t/selenium/testscripts/base/000Login.t" if(!$sel->{_page_opened});
144
    skip("Failed page to load pages!",) if(!$sel->{_page_opened});
145

  
146
    if($sel->get_title() ne "Lx-Office Version 2.4.3 - Selenium - " . $lxtest->{db}){
147
      require "t/selenium/testscripts/base/000Login.t";
148
    }
149

  
150
    $sel->select_frame_ok("relative=up");
151
  }
152
  
153
1;
t/old/selenium/README
1
This directory contains all selenium testscripts for lx-office.
2
Selenium testscrips are the prefered way to test the higher lx 
3
functionalities. For the selenium tests you need to install and
4
run a local selenium server on a machine whitch is able to start 
5
a browser session. See README for more informations.
6

  
7

  
t/old/selenium/TestAccounting.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("accounting/begin", "accounting/end");
4

  
5
1;
t/old/selenium/TestAdmin.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("administration/begin", "administration/end");
4

  
5
1;
t/old/selenium/TestAllTests.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("administration/begin", "system/begin", "masterdata/begin", "selling/begin", "purchase/begin", 
4
            "accounting/begin", "payments/begin", "reports/begin", "programm/begin", 
5
            "programm/end", "reports/end", "payments/end", "accounting/end", "purchase/end", "selling/end",
6
            "masterdata/end", "system/end", "administration/end");
7

  
8
1;
t/old/selenium/TestCreateTestbed.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("administration/begin", "system/begin", "masterdata/begin");
4
  
5
diag("\n\nUsername: " .  $lxtest->{testuserlogin} . "\n" . "Password: " .  $lxtest->{testuserpasswd} . "\n\n");
6

  
7
1;
8

  
t/old/selenium/TestMasterData.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("masterdata/begin", "masterdata/end");
4
  
5
1;
t/old/selenium/TestPayments.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("payments/begin", "payments/end");
4

  
5
1;
t/old/selenium/TestPrinting.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("printing/begin", "printing/end");
4

  
5
1;
t/old/selenium/TestProgramm.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("programm/begin", "programm/end");
4

  
5
1;
t/old/selenium/TestPurchase.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("purchase/begin", "purchase/end");
4

  
5
1;
t/old/selenium/TestReports.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("reports/begin", "reports/end");
4

  
5
1;
t/old/selenium/TestSelling.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("selling/begin", "selling/end");
4

  
5
1;
t/old/selenium/TestSystem.t
1
require "t/selenium/AllTests.t";
2

  
3
init_server("system/begin", "system/end");
4

  
5
1;
t/old/selenium/cleanup.pl
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 Cleanup Script
26
# To clean up all the messy databases and users while debugging testcases
27
# 
28
#######################################################################
29
  no strict;
30
  push @INC, ['/t/selenium'];
31
  use vars qw( $lxdebug $lxtest $sel );
32
  use strict;
33
  use Carp;
34

  
35
  use WWW::Selenium;
36
  use IO::Socket;
37

  
38
  my $cleanedupdb = '';
39
  my $cleanedupusers = '';
40

  
41
  eval { require('t/lxtest.conf'); };
42
  if ($@) {
43
    print "No test configuration found in t/lxtest.conf.\n
44
    Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n";
45
  exit 0;
46
  };
47

  
48
  sub server_is_running {
49
    return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
50
                                 PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
51
                                );
52
  }
53
  if (server_is_running) {
54
  }
55
  else {
56
    exit 0;
57
  }
58

  
59
  $lxtest->{testuserlogin}   = $lxtest->{testlogin};
60
  $lxtest->{db}              = $lxtest->{db};
61

  
62
  $lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
63

  
64
  eval { $sel = WWW::Selenium->new(
65
    host => $lxtest->{seleniumhost},
66
    port => $lxtest->{seleniumport},
67
    browser => $lxtest->{seleniumbrowser},
68
    browser_url => $lxtest->{lxadmin},
69
    auto_stop => '0',
70
    );
71
  };
72
  if ($@) {
73
    print "No Selenium Server running, or wrong preferences\n\n";
74
    exit 0;
75
  }
76

  
77

  
78
  print "\nStarting Testdebugging Cleanup...\n";
79

  
80

  
81
### Delete user
82

  
83
$sel->start;
84
print "Cleanup all users '$lxtest->{testuserlogin}*'\n";
85
$sel->open($lxtest->{lxadmin});
86

  
87
my @links= $sel->get_all_links();
88
my $testuserlogin = $lxtest->{testuserlogin};
89

  
90
foreach my $link (@links) {
91

  
92
  if ($link =~ /$testuserlogin\d\d\d\d\d\d\d\d\d\d/){
93
    $sel->click("link=$lxtest->{testuserlogin}11*");
94
    $sel->wait_for_page_to_load($lxtest->{timeout});
95
    $sel->click("//input[(\@name=\"action\") and (\@value=\"L?schen\")]");
96
    $sel->wait_for_page_to_load($lxtest->{timeout});
97
    $cleanedupusers .= "     $link\n";
98
  }
99
}
100

  
101
print "Lock the system\n";
102
$sel->click("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
103
$sel->wait_for_page_to_load($lxtest->{timeout});
104

  
105
print "Cleanup all test databasees: '$lxtest->{db}*'\n";
106

  
107
  $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
108
  $sel->wait_for_page_to_load($lxtest->{timeout});
109
  $sel->type("dbhost", $lxtest->{dbhost});
110
  $sel->type("dbport", $lxtest->{dbport});
111
  $sel->type("dbuser", $lxtest->{dbuser});
112
  $sel->type("dbpasswd", $lxtest->{dbpasswd});
113
 
114
  $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
115
  $sel->wait_for_page_to_load($lxtest->{timeoutlong});
116

  
117
  my $field = $sel->get_body_text();
118
  my $database= $lxtest->{db};
119
  my @fields = split('  ', $field);
120

  
121
  
122
  foreach my $field (@fields) {
123

  
124
    if ($field =~ /$database\d\d\d\d\d\d\d\d\d\d/){
125
      $sel->open($lxtest->{lxadmin});
126
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
127
      $sel->wait_for_page_to_load($lxtest->{timeout});
128
      $sel->type("dbhost", $lxtest->{dbhost});
129
      $sel->type("dbport", $lxtest->{dbport});
130
      $sel->type("dbuser", $lxtest->{dbuser});
131
      $sel->type("dbpasswd", $lxtest->{dbpasswd});
132
     
133
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
134
      $sel->wait_for_page_to_load($lxtest->{timeoutlong});
135
      $sel->check("name=db value=$field"); 
136
      $sel->click("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
137
      $cleanedupdb .= "     $field\n";
138
      
139
    }
140
  }
141
  
142
$sel->open($lxtest->{lxadmin});
143
print "Unlock the system\n";
144

  
145
$sel->click("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
146
$sel->wait_for_page_to_load($lxtest->{timeout});
147

  
148
$cleanedupdb = "none.\n" if ($cleanedupdb eq '');
149
$cleanedupusers = "none.\n" if ($cleanedupusers eq '');
150

  
151
print "Ready. \nReport:\n--- Cleaned up Users:\n$cleanedupusers---Cleaned up Databases:\n$cleanedupdb";
152

  
153
$sel->stop;
154

  
155
exit 1;
156

  
157

  
t/old/selenium/incomming/ustva-Inland-linet.html
1
<html>
2
<head>
3
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
<title>ustva-Inland-linet</title>
5
</head>
6
<body>
7
<table cellpadding="1" cellspacing="1" border="1">
8
<thead>
9
<tr><td rowspan="1" colspan="3">ustva-Inland-linet</td></tr>
10
</thead><tbody>
11
<!--######################-->
12
<!--# Start Testskript-->
13
<!--# USTVA 2006/2007-->
14
<!--######################-->
15
<!--######################-->
16
<!--#  Datenbank & Benutzer-->
17
<!--#  Umgebung-->
18
<!--######################-->
19
<tr>
20
	<td>break</td>
21
	<td></td>
22
	<td></td>
23
</tr>
24
<tr>
25
	<td>setTimeout</td>
26
	<td>120000</td>
27
	<td></td>
28
</tr>
29
<!--Create new database-->
30
<tr>
31
	<td>selectFrame</td>
32
	<td>relative=top</td>
33
	<td></td>
34
</tr>
35
<tr>
36
	<td>open</td>
37
	<td>https://lx-office.linet-services.de/svn-installationen/unstable/admin.pl?path=bin/mozilla/&rpw=roXyrPyqv9wE2&nextsub=list_users&action=Weiter</td>
38
	<td></td>
39
</tr>
40
<tr>
41
	<td>assertTitle</td>
42
	<td>Lx-Office ERP Administration -</td>
43
	<td></td>
44
</tr>
45
<tr>
46
	<td>clickAndWait</td>
47
	<td>document.forms[0].action[2]</td>
48
	<td></td>
49
</tr>
50
<tr>
51
	<td>assertTitle</td>
52
	<td>Lx-Office ERP / Datenbankadministration -</td>
53
	<td></td>
54
</tr>
55
<tr>
56
	<td>selectWindow</td>
57
	<td>null</td>
58
	<td></td>
59
</tr>
60
<tr>
61
	<td>clickAndWait</td>
62
	<td>action</td>
63
	<td></td>
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff