find_element

 Description:
    Search for an element on the page, starting from the document
    root. The located element will be returned as a WebElement
    object. If the element cannot be found, we will CROAK, killing
    your script. If you wish for a warning instead, use the
    parameterized version of the finders:

        find_element_by_class
        ... etc.
(from Selenium::Remote::Driver)

Which does exist in your script ($mech->find_element_by_name("q");), so does it get killed? Not on my side.

Secondly, there may be some confusion about how these elements are specified. I.e. the parameter to find_element*($string) should it be css, xpath? The warning I got initially for:

Error while executing command: invalid argument: Unknown locator strat +egy css at /usr/local/share/perl5/Selenium/Remote/Driver.pm line 391. at /usr/local/share/perl5/Selenium/Remote/Driver.pm line 348. at /usr/local/share/perl5/Selenium/Remote/Finders.pm line 26.

disappeared when I used:

$mech->find_element_by_xpath('//input[@name="q"]');

Setting the constructor parameter default_finder can be of help.

WWW::Mechanize::Chrome can also be of use here.

Btw, url to get google autocomplete for 'perl'.

https://www.google.com/complete/search?client=psy-ab&gs_rn=64&gs_ri=psy-ab&cp=3&gs_id=jv&q=perl&xhr=t

Btw but irrelevant: notice the client=psy-ab in the above url.

bw, bliako


In reply to Re: Get autocomplete result with Selenium::Remote::Driver by bliako
in thread Get autocomplete result with Selenium::Remote::Driver by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.