in reply to Re^2: One function with 2 calls
in thread One function with 2 calls with Selenium

Now i did this :
my $root ='//a[@href="/"]'; my @name = ('//a[@href="/install/kit"]','//a[@href="/license/view" +); my @snapname = ("Installkit","Licenseview"); sub myHomeTest { my ( $RefName, $RefSnapname ) = @_; my $elem = $driver->find_element($root); # Other way to get Xpa +th: $elem = $driver->find_element("//a[\@href='/']"); $driver->mouse_move_to_location(element => $elem); # xoffset => +x, yoffset => y foreach my $name ( @{RefName}){ $driver->click_element_ok($name, 'xpath', "Loaded"); } $driver->pause(3000); foreach my $name ( @{RefSnapname}){ $driver->capture_screenshot("$path/snap$snapname-$browser.png"); } $driver->get_ok("$base_url","get Home url"); $driver->pause(2000); } myHomeTest ($root, $name, $snapname);
And i have following issue, STDOUT in my Shell:

Variable "$elem" will not stay shared at MyTestingSuite.pm line 169.

Variable "$driver" will not stay shared at MyTestingSuite.pm line 169.

Variable "$root" will not stay shared at MyTestingSuite.pm line 169.

Variable "$browser" will not stay shared at MyTestingSuite.pm line 176.

Global symbol "@RefName" requires explicit package name at MyTestingSuite.pm line 171.

Global symbol "@RefSnapname" requires explicit package name at MyTestingSuite.pm line 175

Global symbol "$snapname" requires explicit package name at MyTestingSuite.pm line 176.

Global symbol "$name" requires explicit package name at MyTestingSuite.pm line 182.

Global symbol "$snapname" requires explicit package name at MyTestingSuite.pm line 182.

Replies are listed 'Best First'.
Re^4: One function with 2 calls
by Corion (Patriarch) on May 10, 2016 at 09:21 UTC

    These error messages mean that your code in MyTestingSuite.pm is very unorganized and structurally mixed. You basically have somewhere the construct of

    sub foo { ... sub bar { ... } ... }

    This is not an error for Perl but very rarely something you want. I suggest that you clean up your code.

    If you cannot clean up the large file, try reducing the file until it has about 20 lines and still produces the error. Then, come back here and post the reduced file together with the error messages you get.