2

Hi I have this short code snippet:

    search_box = self.browser.find_elements_by_id('main-search-box')
    search_box[0].click()
    search_box[0].send_keys('{0} {1}'.format(first_name, last_name))
    search_button = self.browser.find_elements_by_class_name('search-button')
    search_button[0].click()

It used to work but today it suddenly stopped working, it is as the button is not clicked. I changed it to:

    search_box = self.browser.find_elements_by_id('main-search-box')
    search_box[0].click()
    search_box[0].send_keys('{0} {1}'.format(first_name, last_name))
    search_box[0].send_keys('\n')

And now it works fine. What could be the reason for the original code to not work anymore?

P.S I'm searching on LinkedIn using selenium and PhantomJS.

Bob Sacamano
  • 699
  • 15
  • 39

1 Answers1

0

It's happening because in search_box[0].send_keys('\n') so '\n' string gets recognized as the new line! Usually, to go to the next line we press ENTER button =). Basically, '\n' is the standard ASCII newline, while KEY_ENTER represents a keyboard code. Enjoy=)