Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: Problem with around BUILDARGS

by stvn (Monsignor)
on Apr 21, 2011 at 00:49 UTC ( #900445=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Problem with around BUILDARGS
in thread Problem with around BUILDARGS

I would need to see more code, but I suspect that something inside the 'serverLocation' accessor is trying to use the "nameOfTheClass" as if it was an object instance. Show some more context and perhaps I can help.

-stvn


Comment on Re^5: Problem with around BUILDARGS
Replies are listed 'Best First'.
Re^6: Problem with around BUILDARGS
by saintex (Scribe) on Apr 21, 2011 at 08:38 UTC
    Hello, I'm trying to use the accessor as string.

    That is the method in my class:

    sub startServer { my $self = shift; defined(my $pid=fork) or die "Cannot fork: $!"; unless ($pid) { eval { exec 'java -jar '.$self->serverLocation; }; die "Impossibile far partire il server selenium: $@\n;" if ($@ +); } }
    Thank you for your help.

    I'm interested to solve this problem for knowledge reason, not for production... so I'm not in any hurry.

      Can I see the attribute definition for serverLocation? Or better yet, the entire class.

      -stvn
        Hello,
        This is the class.

        Thank you!

        package Selenium2; our $VERSION=0.01; use 5.010; use Moose; use MooseX::NonMoose; use FindBin qw($Bin); use lib ("$Bin/classes","$Bin/classes/browser"); use Test::WWW::Selenium; use WWW::Selenium::Util qw/server_is_running/; extends 'Test::WWW::Selenium'; has 'serverLocation' => (is=>'ro',isa=>'Str',builder =>'buildServerLoc +ation'); sub buildServerLocation { # not: my $self = shift; ?? return "$Bin/lib/selenium-server-standalone-2.0b2.jar" } sub FOREIGNBUILDARGS { my $self = shift; $self->checkServer; my %args = ( @_ == 1 ? %{ $_[0] } : @_ ); $args{serverLocation} //= $self->buildServerLocation; $args{host}//="localhost"; $args{port}//=4444; $args{browser}//='*firefox'; $args{browser_url}//='http://wwww.google.com'; return %args; } sub BUILD { my $self = shift; $self->Browser::BUILD(); $self->start; } sub DEMOLISH { my $self = shift; $self->stop; Browser->DEMOLISH; } sub checkServer { my $self = shift; if (server_is_running) { print "Selenium server running\n"; } else { $self->startServer; } } sub startServer { my $self = shift; defined(my $pid=fork) or die "Cannot fork: $!"; unless ($pid) { eval { exec 'java -jar '.$self->serverLocation; }; die "Impossibile far partire il server selenium: $@\n;" if ($@ +); } sleep(60); #attendi 1 minuto perché il server parta. no Moose; __PACKAGE__->meta->make_immutable; 1; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://900445]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2015-07-30 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls