__author__ = 'snake'

import time
from selenium.webdriver.common.keys import Keys
from classes.asite import ASite

class Leboncoin(ASite):

    def __init__(self, site):
        ASite.__init__(self, site, "FR")

    def browse(self, browser, credentials):

        browser.get('http://www.leboncoin.fr/')

        time.sleep(5)

        if credentials is not None:
            browser.get('http://www2.leboncoin.fr/ai/form/1')

            uname = browser.find_element_by_name('st_username')
            uname.send_keys(credentials['uname'])

            pwd = browser.find_element_by_name('st_passwd')
            pwd.send_keys(credentials['pass'] + Keys.RETURN)

            time.sleep(7)

        #Search

        browser.get('http://www.leboncoin.fr/annonces/offres/provence_alpes_cote_d_azur/')

        searchbar = browser.find_element_by_name('q')
        searchbar.send_keys('guitare' + Keys.RETURN)

