Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: One function with 2 calls

by FloydATC (Deacon)
on May 10, 2016 at 08:49 UTC ( [id://1162607]=note: print w/replies, xml ) Need Help??


in reply to One function with 2 calls with Selenium

Hmm. Aside from the fact that I don't fully understand what you're trying to do, there are a few issues with the code:

You'll have to look carefully at this line and see what exactly you want the string to contain because I can't tell and Perl will complain that it Can't find string terminator '"' anywhere before EOF:
my $root = "'//a[@href="/"]';

Next, you're calling myHomeTest() with dummy arguments (plain words) but that sub doesn't actually seem to use arguments at any point unless there's some magic in the $driver object that I can't see.

Finally, $driver is not defined anywhere so it would just throw Can't call method "find_element" on an undefined value as it is.

When you say it doesn't work, do you mean you get error messages that you can't figure out or does the code just not do what you expect it to?

-- FloydATC

Time flies when you don't know what you're doing

Replies are listed 'Best First'.
Re^2: One function with 2 calls
by Chaoui05 (Scribe) on May 10, 2016 at 09:02 UTC
    Sorry, i am using Selenium ! I will write it in title
      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.

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found