I need to invoke a browser in selenium dynamically.
To achieve this I need to send the browser name as parameter to the set-up or start-up methods in Test::Class
. How do I achieve this?
I need to invoke a browser in selenium dynamically.
To achieve this I need to send the browser name as parameter to the set-up or start-up methods in Test::Class
. How do I achieve this?
I take it you want to get a browser, then reuse it for some tests, then destroy it later? So just use a global to hold the browser you create. For example:
my $browser = '';
sub b_connect : Test(startup) {
$browser = WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*iexplore",
browser_url => "http://www.google.com",
);
};
sub b_disconnect : Test(shutdown) {
$browser->close()
};
Just use the $browser var in you tests.
sub startup : Test( startup ) {
my ($self) = @_;
my $arg = shift;
$self->{browser_type} = $arg->{browser};
-------------------------------#some other code for myself
$self->{browser} =
Test::WWW::Selenium->new(
host => $self->{host},
port => $self->{port},
browser => $self->{browser_type},
browser_url => $self->{test_url},
);
In my test script I need it to call using the following
my $t1 = Test::Class::Selenium::TestCases->new(browser=>$browser,);
Test::Class->runtests($t1);