Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: How to create testcase executor?

by anurag_perl (Novice)
on Dec 22, 2011 at 14:22 UTC ( [id://944787]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to create testcase executor?
in thread How to create testcase executor?

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^5: How to create testcase executor?
by Corion (Patriarch) on Dec 22, 2011 at 15:43 UTC

    I try to keep the links I give relevant. Can you please help me and explain what part was unsatisfactory of the links I gave you? I feel the links I gave you give lots of examples. Please tell me what you expect from the links I gave.

Re^5: How to create testcase executor?
by ww (Archbishop) on Dec 22, 2011 at 19:05 UTC
    Perhaps you forgot to do your 'due diligence' before posting.

    As the contents of PerlMonks FAQ make clear, we'll cheerfully answer a codeless question asked about preferences between modules or alternate algorithms. But your questions amounts to "spoonfeed me" or "gimme some code." That's frowned upon... and why I've downvoted your gimme (particularly in light of the "basic example" code posted earlier.

    The really basic philosophy here (and it's spelled out in the link above) is "we'll help you solve your coding problems, so long as you show you've tried to help yourself." You've posted something over a half dozen questions (in this thread and another you originated) and we've yet to see a single snippet of code or any evidence of constructive effort*1 on your part.

    *1 Where "contructive effort" is defined loosely and charitably, but excludes the act of posting a "gimme."

Re^5: How to create testcase executor?
by anurag_perl (Novice) on Dec 28, 2011 at 11:17 UTC
    Ok Mr.WW(mr.expert) here's my code of effort whic I have done....
    Code : package ELABS_Login; use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More "no_plan"; use Test::Exception; use Log::Fast; sub new { my $class = shift; my %args = (PORT => undef, HOST => undef, SELENIUMHOST => "localhost", SELENIUMPORT => "4444", BROWSER => "googlechrome", LOGFOLDER => undef, @_); my $self = {}; $self->{HOST} = $args{HOST}; $self->{PORT} = $args{PORT}; $self->{SELENIUMHOST} = $args{SELENIUMHOST}; $self->{SELENIUMPORT} = $args{SELENIUMPORT}; $self->{BROWSER} = $args{BROWSER}; bless ($self, $class); $self->{LOG} = $self->_log_init($args{LOGFOLDER}); print "Launching the script on browser $self->{BROWSER}\n"; $self->{HANDLE} = Test::WWW::Selenium->new( host => $self->{SELENI +UMHOST}, port => $self->{SELENIUMPORT}, browser => "*$self->{BROWSER}", browser_url => "http://$self->{HOS +T}:$self->{PORT}", default_names => 1, error_callback => sub { print "Fai +led to load the webpage\n"; }, ); return $self; } sub _log_init { my $self = shift; my $logFolder = shift; $logFolder = "C\:\\Users\\esrirsa\\Documents\\Logs\\" if(!defined +$logFolder); mkdir "$logFolder/screenshots" unless -d "$logFolder/screenshots"; my $pid = $$; my $timestamp = scalar(localtime); $timestamp =~ s/\s+|:/_/g; my $logSuffix = $pid."_".$timestamp; $self->{LOGSUFFIX} = $logSuffix; my $logFileName = $logFolder."elab_".$logSuffix.".log"; print "Log file is $logFileName\n"; open(LOG,">$logFileName") or die "Cannot create such file $! \n"; my $LOG = Log::Fast->new({ level => 'DEBUG', prefix => '%D %T [%L] ', type => 'fh', fh => \*LOG, }); return $LOG; } sub login { my $self = shift; my $user = shift; my $password = shift; my $max_seconds_sleep = 60 if (!defined shift); # Parameters are passed through to WWW::Selenium $self->{LOG}->INFO("Starting the main execution"); $self->{LOG}->INFO("This is the process\_id"); $self->{LOG}->INFO("PID\= $$"); my $sel = $self->{HANDLE}; # use special test wrappers around WWW::Selenium commands: my $initial_page = $sel->open_ok("/login"); my $max_window = $sel->window_maximize(); sleep(5); #if($max_window) { #$self->{LOG}->INFO("Successfully maximized the $self{BROWSER} + window "); #} else { # $self->{LOG}->WARN("Couldn't maximize the $self->{BROWSER} wi +ndow"); #} $sel->type("//div[\@id='username']/input", $user); $sel->type("//div[\@id='pass']/input", $password); $sel->click("//div[\@id='edituser']/div[2]"); my $screenshot_path = $sel->capture_screenshot("C\:\\Users\\esrirs +a\\Documents\\Logs\\Screenshots\\login_screen".$self->{LOGSUFFIX}.".p +ng"); $self->{LOG}->INFO("Checking the screenshot stored in the specifie +d path or not "); $self->{LOG}->INFO($screenshot_path); $sel->wait_for_page_to_load("60000"); #$sel->refresh(); $screenshot_path = $sel->capture_screenshot("C\:\\Users\\esrirsa\\ +Documents\\Logs\\Screenshots\\after_login".$self->{LOGSUFFIX}.".png") +; $self->{LOG}->INFO($screenshot_path); for my $second (0..$max_seconds_sleep) { if($sel->is_text_present("ARTS Quick Launch")) { #print "Expected element found\n"; $self->{LOG}->INFO("Login done succesfully"); $screenshot_path = $sel->capture_screenshot("C\:\\Users\\e +srirsa\\Documents\\Logs\\Screenshots\\successful_login" .$self->{LOGS +UFFIX}.".png"); last; #} elsif ($sel->alert_is("Please close you exist")) { # print "Connection lost to E-LAB server\n"; # $screenshot_path = $sel->capture_screenshot("C\:\\Users\\ +esrirsa\\Documents\\Logs\\Screenshots\\failed_login". # $self->{LOGSUFFIX}.".png"); # $self->{LOG}->WARN("Connection lost to E-LAB server"); # exit; }else { $self->{LOG}->WARN("Could not find the expected string in t +he web page after $second/$max_seconds_sleep seconds attempts\n"); sleep ($second); next; } } sleep(5); $screenshot_path = $sel->capture_screenshot("C\:\\Users\\esrirsa\\ +Documents\\Logs\\Screenshots\\login_successful".$self->{LOGSUFFIX}.". +png"); $self->{LOG}->INFO($screenshot_path); $sel->is_text_present("Welcome to e-Lab"); $self->{LOG}->INFO("The execution is done successfully"); return 1; } 1;
    This is my .pl file code use strict; use warnings; use ELABS_Login; my $elab = new ELABS_Login(HOST=>"155.53.113.65", PORT=>"3000", BROWSE +R => "googlechrome"); $elab->login("eredmoh","Password2");

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-20 04:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found