in reply to Get autocomplete result with Selenium::Remote::Driver

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