# -*- coding: utf-8 -*-
import sys

sys.path.append("/data01/sw/selenium/comm")
import ssgLogger
import time
import commDispMobile
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
import selenium.webdriver as webdriver

reload(sys)
sys.setdefaultencoding("utf-8")

logger = ssgLogger.getLogger("mobile", "mobile.header")

driver = commDispMobile.ssgAppWebDriver()
# fp = webdriver.FirefoxProfile()
# fp.set_preference("general.useragent.override", "SSGAPP")
# driver = webdriver.Firefox(fp)
driver.get("http://m.ssg.com")


def iphone_app_browser(driver):
    cookie1 = {"name": "MOBIL_APP_NO", "value": "12"}
    cookie2 = {"name": "APP_INF", "value": "N%7CHH_FS"}

    driver.add_cookie(cookie1)
    driver.add_cookie(cookie2)
    driver.refresh()
sys.path.append('/data01/sw/selenium/comm')
import ssgLogger
import commDisp
import commDispMobile
import time
import selenium.webdriver as webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from threading import Timer

reload(sys)
sys.setdefaultencoding('utf-8')

logger = ssgLogger.getLogger('mobile', 'mobile.mobile.emart.cart')
err_msg = 'TimeoutError'
result = False


def process_item_list_page_open(driver, device_type):
    global err_msg, result
    try:
        # MOBILE FLOATING LAYER CLEAN.
        js = "$('#header').remove();" \
             "$('#floating-layer').remove();" \
             "$('#lyApp').remove();" \
             "goItemDetail = function(){console.log('item detail page is ignored');};"
        driver.execute_script(js)

        logger.info('item list find start')