传递参数以测试::班级设置方法 [英] Passing Parameter to Test::Class Setup method
本文介绍了传递参数以测试::班级设置方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要硒来调用浏览器动态。
要做到这一点,我需要发送的浏览器的名称作为参数传递给设置或初创于方法试验::类
。我如何做到这一点?
解决方案
子启动:测试(启动){ 我($个体经营)= @_;
我的$ arg =转变; $自> {} browser_type = $ arg-> {}浏览器; -------------------------------#其他一些code为自己 $自> {}浏览器=
测试:: WWW :: Selenium->新建(
主机= GT; $自>(东道国),
端口=> $自>(港口),
浏览器=> $自> {} browser_type,
browser_url => $自> {} test_url,
);
在我的测试脚本我需要使用下面的调用
我的$ T1 =测试::类::硒:: TestCases->新建(浏览器=> $浏览器);
测试::讲座> runtests($ T1);
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?
解决方案
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);
这篇关于传递参数以测试::班级设置方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文