http://www.perlmonks.org?node_id=1033429

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.

Replies are listed 'Best First'.
Re: Using xpath value in selenium web driver in perl
by choroba (Cardinal) 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 redgreen (Priest) 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.
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.