# coding: UTF-8
#Python_v2.7.15
#selenium_v3.12.0
#ChromeDriver_v2.38

from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
import threading
import time

print("*47Club_Test ver1.0*")
test_time = raw_input("input test_time format=Thu May 17 00:00:00 2018>>")
print("---test_start---")

def club47():
    options = Options()
    options.binary_location = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
    options.add_argument('--headless')
    driver = webdriver.Chrome(executable_path="C:\WebDriver\chromedriver.exe")
    driver.get("http://stg-01.47club.jp/aaaa/goods/detail/10060731/")
    time.sleep(10)
    driver.find_element_by_xpath(u"//img[@alt='カートに入れる']").click()
    time.sleep(10)
    driver.find_element_by_xpath(u"//img[@alt='この内容でレジへ進む']").click()
    time.sleep(10)
    driver.find_element_by_link_text(u"会員登録をせずにお買い物されるお客様は、こちら").click()
    driver.find_element_by_id("s_name").click()
    driver.find_element_by_id("s_name").clear()
    driver.find_element_by_id("s_name").send_keys(u"テスト森川")
    driver.find_element_by_name("s_name2").click()
    driver.find_element_by_name("s_name2").clear()
    driver.find_element_by_name("s_name2").send_keys(u"テスト皐雪")
    driver.find_element_by_id("s_kana").click()
    driver.find_element_by_id("s_kana").clear()
    driver.find_element_by_id("s_kana").send_keys(u"テストモリカワ")
    driver.find_element_by_name("s_kana2").click()
    driver.find_element_by_name("s_kana2").clear()
    driver.find_element_by_name("s_kana2").send_keys(u"テストサユキ")
    driver.find_element_by_id("yy_s_birth").click()
    Select(driver.find_element_by_id("yy_s_birth")).select_by_visible_text("1998")
    driver.find_element_by_id("yy_s_birth").click()
    driver.find_element_by_name("mm_s_birth").click()
    Select(driver.find_element_by_name("mm_s_birth")).select_by_visible_text("05")
    driver.find_element_by_name("mm_s_birth").click()
    driver.find_element_by_name("dd_s_birth").click()
    Select(driver.find_element_by_name("dd_s_birth")).select_by_visible_text("30")
    driver.find_element_by_name("dd_s_birth").click()
    driver.find_element_by_id("s_mail").click()
    driver.find_element_by_id("s_mail").clear()
    driver.find_element_by_id("s_mail").send_keys("sayuki.morikawa@nadai.jp")
    driver.find_element_by_id("s_cmail").click()
    driver.find_element_by_id("s_cmail").clear()
    driver.find_element_by_id("s_cmail").send_keys("sayuki.morikawa@nadai.jp")
    driver.find_element_by_id("s_zip").click()
    driver.find_element_by_id("s_zip").clear()
    driver.find_element_by_id("s_zip").send_keys("2520144")
    driver.find_element_by_id("s_pref").click()
    Select(driver.find_element_by_id("s_pref")).select_by_visible_text(u"神奈川県")
    driver.find_element_by_id("s_pref").click()
    driver.find_element_by_id("s_addr").click()
    driver.find_element_by_id("s_addr").clear()
    driver.find_element_by_id("s_addr").send_keys(u"相模原市緑区")
    driver.find_element_by_id("s_addr2").click()
    driver.find_element_by_id("s_addr2").clear()
    driver.find_element_by_id("s_addr2").send_keys(u"東橋本4-2-35-3")
    driver.find_element_by_id("s_tel").click()
    driver.find_element_by_id("s_tel").clear()
    driver.find_element_by_id("s_tel").send_keys("08026118642")
    driver.find_element_by_name("submit").click()
    time.sleep(10)
    driver.find_element_by_xpath("//input[@id='method_r6']").click()
    driver.find_element_by_xpath("//input[@id='conbi_1']").click()
    driver.find_element_by_name("submit").click()
    time.sleep(10)
    while(1==1):
        if test_time <= time.ctime():
            driver.find_element_by_xpath(u"//img[@alt='注文を確定する']").click()
            break
    time.sleep(10)

if __name__=="__main__":
    th1 = threading.Thread(target=club47)
    th2 = threading.Thread(target=club47)
    th3 = threading.Thread(target=club47)
    th4 = threading.Thread(target=club47)
    th5 = threading.Thread(target=club47)
    th6 = threading.Thread(target=club47)
    th7 = threading.Thread(target=club47)
    th8 = threading.Thread(target=club47)
    th9 = threading.Thread(target=club47)
    th10 = threading.Thread(target=club47)
    th11 = threading.Thread(target=club47)
    th12 = threading.Thread(target=club47)
    th13 = threading.Thread(target=club47)
    th14 = threading.Thread(target=club47)
    th15 = threading.Thread(target=club47)
	
    th1.start()
    th2.start()
    th3.start()
    th4.start()
    th5.start()
    th6.start()
    th7.start()
    th8.start()
    th9.start()
    th10.start()
    th11.start()
    th12.start()
    th13.start()
    th14.start()
    th15.start()