Chaoui05 has asked for the wisdom of the Perl Monks concerning the following question:
use Modern::Perl; use strict; use warnings; package MyTestingSuite; use parent 'Test::Class'; use Test::Selenium::Remote::Driver; use Test::More; use POSIX qw(strftime); my $start = time(); cprint "Started at ", (strftime '%A %d %B %Y %H:%M:%S',localtime($star +t)), "\n"; sub startup : Test( startup => no_plan ) { my $self = shift; $self->{browsers} = [('firefox', 'internet explorer', 'chrome', 'pha +ntomjs')]; } # WHEN I PUT MY END TIME HERE: my $end = time(); cprint "Ended at ", (strftime '%A %d %B %Y %H:%M:%S', localtime($end +)),"\n"; cprintf "Total run time:", $end-$start, " seconds\n"; printf ("%02d:%02d:%02d\n",(gmtime($end-$start))[2,1,0]); I HAVE THIS OUTPUT IN MY SHELL: Started at 2016-05-17-16-55-00 1..0 Ended at 2016-05-17-16-57-04 Total run time:0 seconds .....ALL MY TESTS ..... sub Login_test : Tests { $driver->quit(); } } sub Logout_test : Tests { $driver->quit(); } } sub Navigation_test : Tests { $driver->quit(); } # WHEN I PUT MY END TIME HERE: my $end = time(); cprint "Ended at ", (strftime '%A %d %B %Y %H:%M:%S', localtime($end +)),"\n"; cprintf "Total run time:", $end-$start, " seconds\n"; printf ("%02d:%02d:%02d\n",(gmtime($end-$start))[2,1,0]); I HAVE THIS OUTPUT IN MY SHELL: Started at 2016-05-17-16-57-04 1..0 ....ALL MY TESTS ..... Ended at 2016-05-17-17-03-04 Total run time:360 seconds }
So in second position, inside Sub, it works fine , because i have all my tests inside my timer and so i can have elapsed time. But problem is that i can have random sub in my test . Also even if i place my end timer in the last Sub it can cut my timer inside my tests and not at the end of end.
I think about a conditionnal loop to get all my sub when they finish all to call my end time but i don't know how .
How can i do?
Many Thanks !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Time elapsed with Selenium Test
by Corion (Patriarch) on May 17, 2016 at 15:31 UTC | |
by Chaoui05 (Scribe) on May 17, 2016 at 15:46 UTC | |
by Chaoui05 (Scribe) on May 17, 2016 at 15:48 UTC | |
by soonix (Chancellor) on May 18, 2016 at 07:15 UTC | |
by Chaoui05 (Scribe) on May 18, 2016 at 08:03 UTC | |
by Corion (Patriarch) on May 18, 2016 at 08:05 UTC | |
|