Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Using xpath value in selenium web driver in perl

by Shaveta_Chawla (Acolyte)
on May 14, 2013 at 07:19 UTC ( #1033429=perlquestion: print w/ replies, xml ) Need Help??
Shaveta_Chawla has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a cutton with xpath as below:
id('GoAheadAndLogIn')
I am using below code :
$driver->find_element("//input[\@id='GoAheadAndLogIn']"); $driver->mouse_move_to_location(element => $elem, xoffset => 0, yoffse +t => 0); $driver->click;
but selenium web driver displays the error that the element could not be located. Please suggest how to use xpath value for clickable item.

Comment on Using xpath value in selenium web driver in perl
Download Code
Re: Using xpath value in selenium web driver in perl
by choroba (Abbot) on May 14, 2013 at 07:22 UTC
    Crossposted at StackOverflow. It is considered a courtesy to inform about crossposting so people not attending both sites do not waste their times solving a problem already solved at the other end of the Internets.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Using xpath value in selenium web driver in perl
by Anonymous Monk on May 14, 2013 at 07:29 UTC

    What does find_element() return?

    What is  $elem and where does it come from?

      The complete code is as follows:
      use Selenium::Remote::Driver; my $driver = new Selenium::Remote::Driver(); $driver->get('some url'); $driver->find_element("//input[\@name='login']")->send_keys('username' +); $driver->find_element("//input[\@name='password']")->send_keys('passwo +rd'); my $elem = $driver->find_element("//input[\@id='GoAheadAndLogIn']"); $driver->mouse_move_to_location(element => $elem, xoffset => 0, yoffse +t => 0); $driver->click;
Re: Using xpath value in selenium web driver in perl
by sundialsvc4 (Abbot) on May 14, 2013 at 13:42 UTC

    An “interactive XPath tester” such as the one at http://http://www.xpathtester.com/ is a very valuable tool.   Extract the actual stream that you’re getting from the host, paste it into the appropriate window, then try your expression against it.   Good thing to have on your browser’s bookmarks-bar.

Re: Using xpath value in selenium web driver in perl
by redgreen (Curate) on May 14, 2013 at 17:16 UTC
    In the past I have found the FirePath add-on for Firebug an excellent way to test XPath expressions.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1033429]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-20 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls