$ENV{'DISPLAY'} = ':0.0'; #allows script to run when called from remote terminal window use X11::GUITest qw/SendKeys FindWindowLike ClickWindow SetEventSendDelay/; use Moose; use MooseX::NonMoose; extends 'WWW::Mechanize::Firefox'; has 'window_id' => ( is => 'rw', isa => 'Int', ); sub BUILD { my $self = shift; $self->window_id(FindWindowLike('Mozilla Firefox')); ClickWindow($self->window_id); }