from selenium import webdriver
import random
from selenium.webdriver.support.ui import Select
import string
driver = webdriver.Chrome()
driver.get('http://localhost/Litecart/en/')
driver.implicitly_wait(10)
reg_link = driver.find_element_by_link_text('New customers click here')
reg_link.click()
driver.implicitly_wait(10)
digits = "".join([random.choice(string.digits) for i in range(5)])
chars = "".join([random.choice(string.ascii_letters[:26])for i in range(8)])
driver.find_element_by_css_selector('[name = firstname]').send_keys(chars)
driver.find_element_by_css_selector('[name = lastname]').send_keys(chars)
driver.find_element_by_css_selector('[name = address1]').send_keys(chars)
driver.find_element_by_css_selector('[name = postcode]').send_keys(digits)
driver.find_element_by_css_selector('[name = city]').send_keys("".join([random.choice(string.ascii_letters[:26])for i in range(6)]))
email = "".join([random.choice(string.digits) for i in range(8)])+"@gmail.com"
driver.find_element_by_css_selector('[name = email]').send_keys(email)
driver.find_element_by_css_selector('[name = phone]').send_keys('1232562859')
Select(driver.find_element_by_name("country_code")).select_by_value("US")
Select(driver.find_element_by_css_selector("select[name=zone_code]")).select_by_visible_text("Arizona")
driver.find_element_by_css_selector('[name = password]').send_keys('Test123')
driver.find_element_by_css_selector('[name = confirmed_password]').send_keys('Test123')
driver.find_element_by_css_selector('button').click()
driver.implicitly_wait(10)
Logout = driver.find_element_by_link_text('Logout')
Logout.click()
driver.implicitly_wait(10)
driver.find_element_by_css_selector('[name = email]').send_keys(email)
driver.find_element_by_css_selector('[name = password]').send_keys('Test123')
driver.find_element_by_css_selector('[name = login]').click()
driver.implicitly_wait(10)
driver.quit()
