อีกไฟล์ 1 ครับ ที่เรียกใช้
[code]from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.select import Select
import time, base64, re, requests ,unittest,os
user = ""
password = ""
user1 = "ธวัชชัย แสนหาญ"
password1 = ""
user2 ='mt77'
password2 =''
path = r'E:\geckodriver-v0.23.0-win64\geckodriver.exe'
wed0 = "http://mzc.xxxx.com/administrator/index.php"
wed1 = "http://mzc.xxxx.com/index.php/en/"
wed_mindphp = "https://www.xxxx.com/xxxx/viewforum.php?f=342"
firefoxpath = "/home/com015/geckodriver"
Toggle = "//a[contains(.,'Toggle editor')]"
new = '.button-new'
save = '.button-apply'
save_close ='.button-save'
Cancel ='.button-cancel'
Public ='.button-publish'
Unpublic ='.button-unpublish'
delete ='#toolbar-delete > button.btn.btn-small'
Detail ='Details'
pw1 ='passwd'
pw2 ='password'
'categories'
CategoryTitle = 'book'
CategoryTitle1 = 'Book'
Alias ='book'
Short_description = 'book'
Description = 'book'
Access ='Public'
Category_sorting ='First'
Amount_of_products_on_page ='10'
Amount_of_products_in_row ='5'
Parent_category ='Top level'
categoriesfile_edit ='book'
'Product'
ProductTitle = 'One Piece'
ProductTitle1 = 'One Piece2'
ProductAlias = 'One Piece'
ProductShort_description = 'One Piece'
ProductDescription = 'One Piece'
access = 'Public'
price = '30'
currency = 'บาท'
Amount_of_product_in_stock = '20'
tax_id = 'Normal (5.00%)'
category_id = 1
lable = 'No'
Productfile_edit = 'One Piece'
'Clients'
ClientsUsername = 'MT001'
ClientsUsername1 = 'MT0011'
ClientsEmail = '
[email protected]'
ClientsPassword = '543210'
ClientsUsergroup = 'group A'
Clientsfile_edit = 'MT001'
'Manufacturers'
ManufacturersTitle = 'test Grand Home (Chaina) Co.,Ltd.'
ManufacturersTitle1 = 'Grand Home (Chaina) Co.,Ltd.'
ManufacturersAlias = 'Grand Home'
ManufacturersShort_description = 'Grand Home (Chaina)'
ManufacturersDescription = 'Grand Home (Chaina) Co.,Ltd.'
ManufacturersURL = 'www.GrandHome.co.th'
ManufacturersAmount_of_products_on_page ='10'
ManufacturersAmount_of_products_in_row ='10'
Manufacturersfile_edit = 'test Grand Home (Chaina) Co.,Ltd.'
'Coupons'
CouponsCode = '300'
CouponsCode1 = '3000'
Coupons_type_n = 1 #"(Percent)=1 ; (Value)=2"
CouponsValue = '30'
CouponsStart_date = '2018-12-15'
CouponsExpire_date = '2019-12-25'
Couponsfor_user_id = '0'
Couponsfile_edit = '300'
'Currencies'
Currencies_Title = 'USD'
Currencies_Title1 = 'USD1'
Currencies_Code = 'USD'
Code_ISO = 'USD'
Code_Numeric = 'USD'
Course_of_exchange = '1'
Currenciesfile_edit = 'USD'
'Bank'
Bank_Code = 'Asia Bank'
Bank_Name = 'test ธนาคารเอเชีย(มหาชน)'
Bank_Name1 = 'test1 ธนาคารเอเชีย(มหาชน)'
Bankfile_edit = 'test ธนาคารเอเชีย(มหาชน)'
'Taxes'
Tax_Title = 'ภาษี ณ ที่จ่าย'
Tax_Title1 = 'ภาษี ข่นส่ง'
Tax_Value = '10'
Extended_rule_tax = 2
List_of_tax_rules_Title='ภาษี ณ ที่จ่าย (10.00%)'
List_of_tax_rules_Country='209'
Tax='22'
Company_tax='11'
Taxesfile_edit = 'ภาษี ณ ที่จ่าย'
'Payment'
Title_Payment = "Coupon payments"
Title_Payment1 = "mobile payments"
Alias_Payment = "pm_Coupon"
Alias_Payment1 = "pm_mobile"
Please_select_tax_Payment = "ภาษี ณ ที่จ่าย (10.00%)"
Paymentfile_edit = 'Coupon payments'
'Shipping methods'
Shippingfile_edit = 'Free Shipping'
Title_Shipping = "Free Shipping"
Title_Shipping1 = "Flat Rate"
Delivery_methods_prices = 3
Country_Shipping = 1
Price_Shipping = 0
Tax_Shipping = "ภาษี0% (0.00%)"
Tax_Shipping1 = "Normal (5.00%)"
Package_Price_Shipping = 0
Package_Tax_Shipping = "ภาษี0% (0.00%)"
Package_Tax_Shipping1 = "Normal (5.00%)"
'Delivery time'
Title_en = 'test003'
Title_en1 = 'test033'
Title_th = 'test003'
Days = '30'
Delivery_timefile_edit = 'test003'
'Order status'
status_Title_en = 'Return the product'
status_Title_en1 = 'R t p'
status_Title_th = 'Return the product'
status_Code = 'r'
Order_statusfile_edit = 'Return the product'
'Country list'
Country_Title_en = 'test Mexico'
Country_Title_en1 = 'test1 Mexico'
Country_Title_th = 'Mexico'
Country_Code = 'Mex'
Country_Code2 = 'Mx'
Country_listfile_edit = 'test Mexico'
'Province'
Province_Code = '59'
Province_Name_en = 'Nakhon Pathom'
Province_Name_en1 = 'Nakhon Pathom1'
Province_Name_th = 'นครปฐม'
Provincefile_edit = 'Nakhon Pathom'
'Amphur'
ProvinceName = '58'
AmphurCode = '7308'
AmphurName_en = 'Kamphangsang'
AmphurName_en1 = 'Kamphangsang1'
AmphurName_th = 'กำแพงแสน'
Postcode = '17308'
Amphurfile_edit = 'Kamphangsang'
'District'
District_ProvinceName = '58'
District_AmphurName = '2'
Districtcode = '730209'
DistrictName_en = 'Thung Khwang'
DistrictName_en1 = 'Thung Khwang1'
DistrictName_th = 'ทุ่งขวาง'
Districtfile_edit = 'Thung Khwang'
'Attributes'
Attributes_Title_en = 'light'
Attributes_Title_en1 = 'light1'
Attributes_Title_th = 'light'
Type = 'Radio'
Dependent = '1' # 0,1
Show_for_categories = '1'
category_No = '1'
Attributesfile_edit = 'light'
'Free_attributes'
Free_attributesfile_edit ='solid'
Free_attributes_Title_en ='solid'
Free_attributes_Title_en1 ='solid1'
Free_attributes_Title_th ='ของแข็ง'
Free_attributes_description_en ='solid'
Free_attributes_description_th ='ของแข็ง'
'Units of measure'
unit_en='m'
unit_en1 = 'mm'
unit_th='m'
unitfile_edit='m'
'User groups'
Usergroups_Title_en='group1'
Usergroups_Title_en1='group11'
Usergroups_Title_th='group1'
Discount='20'
Description_en='Customers1'
Description_th='Customers1'
User_groupsfile_edit = 'group1'
'Product comments'
prodoct_ID = '27'
Productuser = 'mt27'
Productemail = '
[email protected]'
comment = 'ดี'
Product_commentsfile_edit = 'football'
'Product labels'
name_en = 'SALE 40%'
name_en1 = 'SALE 45%'
name_th = 'ลดราคา 40%'
Product_labelsfile_edit = 'SALE 40%'
'Product Characteristics'
P_C_edit ='fluid'
P_C_Title_en ='fluid'
P_C_Title_en1 ='fluid1'
P_C_Title_th ='ของเหลว'
P_C_description_en ='fluid'
P_C_description_th ='ของเหลว'
Show_categories_All ='tr:nth-child(5) #\31-lbl'
Show_categories_selected ='#allcats0'
P_C_Show_categories =Show_categories_selected
P_C_categories = 1 #category_id > option:nth-child(2)
Type_List='#type0'
Type_Multiple_List='#\-1'
Type_Text='tr:nth-child(7) #\31'
P_C_Type =Type_List
'Import & Export'
file = 'Simple Export'
file_name = 'Export02'
Import_Exportfile_edit = 'Export02'
'Create_Account'
cneme = 'botmt27'
cusername = 'botmt27'
cpassword = 'botmt27007'
cemail = '
[email protected]'
'Cart'
Category ='sport'
Product ='football'
Title ='Mr.'
First_name ='mt77'
Last_name ='mt77'
Email ='
[email protected]'
Street_No ='77'
Postal_Code ='73140'
City ='1'
Country ='Thailand'
phone ='0929462162'
payment =1
Update_cart ='.quantity img'
Back_to_shop ='.btn-arrow-left'
Buy =2
information_css ="input[name='rabatt']"
Delete=1
Activate ='.button.btn'
directory='report'
Standard='.name:nth-child(1) b'
Express='.name:nth-child(2) b'
class joomla(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox(executable_path=path) # __builtin__.firefoxpath)
self.base_url = wed0 # __builtin__.base_url #=
self.base_url1 = wed1 # __builtin__.base_url1 #=
self.username = user # __builtin__.username #=
self.username1 = user1 # __builtin__.username1 #=
self.username2 = user2 # __builtin__.username1 #=
self.pwd = password # __builtin__.pwd #=
self.pwd1 = password1 # __builtin__.pwd1 #=
self.pwd2 = password2 # __builtin__.pwd1 #=
self.verificationErrors = []
self.accept_next_alert = True
self.wait = WebDriverWait(self.driver, 10)
# self.driver.maximize_window()
def msg_error(self):
for i in range(5):
try:
if self.driver.find_element_by_css_selector("div.alert.alert-error"):
obj = self.driver.find_element_by_css_selector("div.alert.alert-error")
msg = obj.text
self.msg = msg
break
except:
pass
print(i)
time.sleep(1)
else:
msg = "ไม่มี"
self.msg = msg
def report_error(self):
'Report'
Error_test = self.case
Error_test1 = str(Error_test)
driver = self.driver
# obj = self.driver.find_element_by_xpath("/html/body")
# msg = obj.text
self.msg_error()
Url = self.driver.current_url # เก็บ URL ไว้ในตัวแปร
snap = self.driver.get_screenshot_as_base64()
text = str(snap)#snap
base = "data:image/png;base64," + text
url = "http://snap.mindphp.com/index.php"
files = {'paths': base, 'upload': 'upload', 'from_python': 'true'}
response = requests.post(url, data=files)
url_img = response.text
url_snap_img = "http://snap.mindphp.com/index.php%s" % url_img
self.driver.get(wed_mindphp)
for i in range(4):
try:
if self.driver.find_element_by_name("username"):
login = self.wait.until(ec.visibility_of_element_located((By.NAME, "username")))
ActionChains(self.driver).move_to_element(login).perform()
a = self.driver.find_element_by_name("username")
a.clear()
a.send_keys(user1)
a = self.driver.find_element_by_name("password")
a.clear()
a.send_keys(password1)
time.sleep(3)
self.driver.find_element_by_name("login").click()
time.sleep(5)
print('login')
break
except:
if self.driver.find_element_by_link_text("ตั้งกระทู้ใหม่"):
print("ตั้งกระทู้ใหม่")
break
pass
print("ทำใหม่")
time.sleep(2)
else:
print("error")
self.driver.find_element_by_link_text("ตั้งกระทู้ใหม่").click()
a = self.driver.find_element_by_name("subject")
a.clear()
a.send_keys("B - เว็บระบบของ Moozii cart มีปัญหาที่ %s" % Error_test1)
a = self.driver.find_element_by_name("message")
a.clear()
a.send_keys("[color=#FF0000][size=150]เกิดปัญหา moozii cart ขัดข้อง ที่ Case %s[/size][/color]\n"% Error_test1)
a.send_keys('\n')
a.send_keys('ข้อความError : [color=#FF0000]%s[/color] \n' % self.msg)
a.send_keys('ตำแหน่งที่ Error : [color=#FF0000]%s[/color] \n' % self.msg1)
a.send_keys('link error : %s \n' % Url)
a.send_keys('user : %s\n' % user)
a.send_keys('password : %s\n' % password)
a.send_keys('[img]%s[/img]\n' % url_snap_img)
# self.driver.find_element_by_name("post").click()
self.driver.find_element_by_name("preview").click()
time.sleep(15)
driver.quit()
def openwed_Login(self,elementpwd,wed,user,password):
'Login เข้าระบบ Joomla'
self.case = self.openwed_Login.__doc__
self.driver.get(wed)
driver = self.driver
for i in range(10):
try:
if self.driver.find_element_by_name("username"):
break
print(self.driver.get(wed))
except:
pass
print("ทำใหม่")
time.sleep(2)
else:
print("error")
self.msg1 = 'wed error'
self.report_error()
driver.quit()
login = self.wait.until(ec.visibility_of_element_located((By.NAME, "username")))
ActionChains(self.driver).move_to_element(login).perform()
a = self.driver.find_element_by_name("username")
a.clear()
a.send_keys(user)
a = self.driver.find_element_by_name(elementpwd)
a.clear()
a.send_keys(password)
a = self.driver.find_element_by_css_selector(".btn-primary")
a.submit()
time.sleep(5)
def menu_MooZiiCart(self,menu):
menu = menu
driver = self.driver
self.wait.until(ec.visibility_of_element_located((By.LINK_TEXT, "Components")))
self.driver.find_element_by_link_text("Components").click()
for i in range(10):
try:
if self.driver.find_element_by_link_text("MooZiiCart"):break
except:
pass
print("หาใหม่")
time.sleep(2)
else:
print("error")
self.msg1 = 'MooZiiCart'
self.report_error()
driver.quit()
time.sleep(2)
self.driver.find_element_by_link_text("MooZiiCart").click()
for i in range(10):
try:
if self.driver.find_element_by_xpath("//span[contains(.,'%s')]"%menu): break
except:
pass
time.sleep(2)
else:
print ("report bug")
self.msg1 = menu
self.report_error()
driver.quit()
time.sleep(3)
self.driver.find_element_by_xpath("//span[contains(.,'%s')]" % menu).click()
def xpath_click(self, element):
for i in range(10):
try:
if self.driver.find_element_by_xpath(element):break
except:
pass
print('x%d' % i)
time.sleep(2)
else:
print ("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
self.driver.find_element_by_xpath(element).click()
def find(self, element):
for i in range(10):
try:
if self.driver.find_element_by_xpath(element):break
except:
pass
print('x%d' % i)
time.sleep(2)
else:
print ("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
element1 = self.driver.find_element_by_xpath(element)
self.driver.execute_script("arguments[0].click();", element1)
def find_css(self, element):
for i in range(10):
try:
if self.driver.find_element_by_css_selector(element): break
except:
pass
time.sleep(2)
else:
print("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
self.driver.find_element_by_css_selector(element).click()
def find_linktext(self, element):
for i in range(10):
try:
if self.driver.find_element_by_link_text(element): break
except:
pass
time.sleep(2)
else:
print("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
self.driver.find_element_by_link_text(element).click()
def Confirm(self):
obj = self.driver.switch_to.alert
msg = obj.text
print("Alert shows following message: " + msg)
time.sleep(2)
obj.accept()
print(" Clicked on the OK Button in the Alert Window")
time.sleep(5)
def information_name (self,element,information):
for i in range(10):
try:
if self.driver.find_element_by_name(element):
a = self.driver.find_element_by_name(element)
a.clear()
a.send_keys(information)
break
except:
pass
print("pass%d"%i)
time.sleep(2)
else:
print ("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
def open_file(self,file):
for i in range(10):
try:
if self.driver.find_element_by_xpath("//a[contains(.,'%s')]" % file):
break
except:
pass
print('หาใหม่')
time.sleep(1)
else:
print("Error")
self.msg1 = file
self.report_error()
self.driver.quit()
time.sleep(3)
element1 = self.driver.find_element_by_xpath("//a[contains(.,'%s')]" % file)
self.driver.execute_script("arguments[0].click();", element1)
def check_file(self,file):
for i in range(10):
try:
if self.driver.find_element_by_xpath("//a[contains(.,'%s')]" % file):
break
except:
pass
print('check file : %d' % i)
time.sleep(1)
else:
print("Error")
self.msg1 = file
self.report_error()
self.driver.quit()
print('check pass')
def Dropdown(self,element,text):
for i in range(10):
try:
if self.driver.find_element_by_name(element):break
except:
pass
time.sleep(2)
else:
print ("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
select = Select(self.driver.find_element_by_name(element))
select.select_by_visible_text(text)
def box(self, boxtr ,boxtd):
print("xpath=//form[@id='adminForm']/table/tbody/tr[%d]/td[%d]/input" %(boxtr,boxtd))
for i in range(10):
try:
if self.driver.find_element_by_xpath("//form[@id='adminForm']/table/tbody/tr[%d]/td[%d]/input" %(boxtr,boxtd)):
element1 = self.driver.find_element_by_xpath("//form[@id='adminForm']/table/tbody/tr[%d]/td[%d]/input" % (boxtr, boxtd))
self.driver.execute_script("arguments[0].click();", element1)
break
except:
pass
time.sleep(2)
else:
print('error box')
self.msg1 = "box%d"%boxtr
self.report_error()
self.driver.quit()
def menu_buy (self,buy):
for i in range(10):
try:
if self.driver.find_element_by_xpath("(//a[contains(text(),'Buy')])[%d]" %buy):break
except:
pass
time.sleep(2)
else:
print ("Error")
self.msg1 = "Buy%d"%buy
self.report_error()
self.driver.quit()
time.sleep(3)
element1 = self.driver.find_element_by_xpath("(//a[contains(text(),'Buy')])[%d]" %buy)
self.driver.execute_script("arguments[0].click();", element1)
def information_css (self,element,information):
for i in range(10):
try:
if self.driver.find_element_by_css_selector(element):break
except:
pass
print("pass")
time.sleep(2)
else:
print ("Error")
self.msg1 = element
self.report_error()
self.driver.quit()
time.sleep(3)
a = self.driver.find_element_by_css_selector(element)
a.send_keys(information)
def check_Delete(self, check):
for i in range(5):
try:
if self.driver.find_element_by_css_selector(".row0:nth-child(1) #cb0"):break
except:
pass
time.sleep(1)
else:
self.msg1 = "wed error"
self.report_error()
self.driver.quit()
for i in range(5):
try:
if self.driver.find_element_by_xpath("//a[contains(.,'%s')]" % check):
print('c1')
self.report_error()
break
except:
pass
else:
print('check pass')
self.driver.quit()
def check_show(self ,box ,td):
n = box % 2
if n == 1:
m = n - 1
else:
m = n + 1
print('.row%d:nth-child(%d) > td:nth-child(%d) > a'% (m, box, td))
for i in range(10):
try:
if self.driver.find_element_by_css_selector('.row%d:nth-child(%d) > td:nth-child(%d) > a'% (m, box, td)):
ojb = self.driver.find_element_by_css_selector('.row%d:nth-child(%d) > td:nth-child(%d) > a' % (m, box,td))
msg = ojb.text
self.msg1 = msg #.row0:nth-child(3) > td:nth-child(3) > a
break
except:
pass
print(i)
time.sleep(1)
else:
print('error check show')
self.msg1 = 'ไม่มี box%d'%box
self.report_error()
self.driver.quit()
def check_show_P_A_D(self, box, td):
print('.row0:nth-child(%d) > td:nth-child(%d) > a' % ( box, td))
for i in range(10):
try:
if self.driver.find_element_by_css_selector('.row0:nth-child(%d) > td:nth-child(%d) > a' % ( box, td)):
ojb = self.driver.find_element_by_css_selector('.row0:nth-child(%d) > td:nth-child(%d) > a' % (box, td))
msg = ojb.text
self.msg1 = msg # .row0:nth-child(3) > td:nth-child(3) > a
break
except:
pass
print(i)
time.sleep(1)
else:
print('error check show')
self.msg1 = 'ไม่มี box%d' % box
self.report_error()
self.driver.quit()
def Options(self):
'Options'
self.openwed_Login(pw1, self.base_url, self.username, self.pwd)
self.case = self.Options.__doc__
self.menu_MooZiiCart('Options')
def Configuration(self):
'Options'
self.openwed_Login(pw1, self.base_url, self.username, self.pwd)
self.case = self.Options.__doc__
self.menu_MooZiiCart('Configuration')
class MooZiiCart_check(joomla):
def Shop_functions_check_Add(self):
'Add categories'
driver = self.driver
self.Configuration()
self.case = self.Shop_functions_check_Add.__doc__
self.menu_MooZiiCart("Shop functions")
self.find_css(new)
self.find(Toggle)
self.information_name('name_en-GB',CategoryTitle)
self.information_name('alias_en-GB',Alias)
self.information_name('short_description_en-GB', Short_description)
self.information_name('description1', Description)
self.find_linktext('Description (th)')
self.information_name('name_th-TH', CategoryTitle)
self.information_name('alias_th-TH', Alias)
self.information_name('short_description_th-TH', Short_description)
self.find("//*[@id='th-TH-page']/div[1]/table/tbody/tr[4]/td[2]/div/div[2]/div/a")
self.information_name('description2', Description)
self.find_linktext(Detail)
self.Dropdown('access',Access)
self.Dropdown('ordering',Category_sorting)
self.information_name('products_page',Amount_of_products_on_page)
self.information_name('products_row',Amount_of_products_in_row)
self.Dropdown('category_parent_id',Parent_category)
self.find_css(save_close)
self.check_file(CategoryTitle)
driver.quit()
def categories_check_Add(self):
'Add categories'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.categories_check_Add.__doc__
self.menu_MooZiiCart("Categories")
self.find_css(new)
self.find(Toggle)
self.information_name('name_en-GB',CategoryTitle)
self.information_name('alias_en-GB',Alias)
self.information_name('short_description_en-GB', Short_description)
self.information_name('description1', Description)
self.find_linktext('Description (th)')
self.information_name('name_th-TH', CategoryTitle)
self.information_name('alias_th-TH', Alias)
self.information_name('short_description_th-TH', Short_description)
self.find("//*[@id='th-TH-page']/div[1]/table/tbody/tr[4]/td[2]/div/div[2]/div/a")
self.information_name('description2', Description)
self.find_linktext(Detail)
self.Dropdown('access',Access)
self.Dropdown('ordering',Category_sorting)
self.information_name('products_page',Amount_of_products_on_page)
self.information_name('products_row',Amount_of_products_in_row)
self.Dropdown('category_parent_id',Parent_category)
self.find_css(save_close)
self.check_file(CategoryTitle)
driver.quit()
def Product_check_Add(self):
'Add Product'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.Product_check_Add.__doc__
self.menu_MooZiiCart('Products')
self.find_css(new)
self.find(Toggle)
self.information_name('name_en-GB', ProductTitle)
self.information_name('alias_en-GB', ProductAlias)
self.information_name('short_description_en-GB', ProductShort_description)
self.information_name('description1', ProductDescription)
self.find_linktext('Description (th)')
self.information_name('name_th-TH', ProductTitle)
self.information_name('alias_th-TH', ProductAlias)
self.information_name('short_description_th-TH', ProductShort_description)
self.find("//*[@id='th-TH-page']/div[1]/table/tbody/tr[4]/td[2]/div/div[2]/div/a")
self.information_name('description2', ProductDescription)
self.find_linktext(Detail)
self.Dropdown('access',access)
self.information_name('product_price',price)
self.Dropdown('currency_id',currency)
self.information_name('product_quantity', Amount_of_product_in_stock)
self.Dropdown('product_tax_id', tax_id)
self.find_css("#category_id > option:nth-child(%d)" % category_id)
self.Dropdown('label_id', lable)
self.find_css(save_close)
self.check_file(ProductTitle)
driver.quit()
def Orders_check_Add(self):
'Add Orders'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.Orders_check_Add.__doc__
self.menu_MooZiiCart('Orders')
self.find_css(new)
self.find_css(".span10 > input")
self.Dropdown('user_id','MT27 mt27')
self.find("//input[@value='Add Product']")
self.find("(//a[contains(text(),'Load')])[2]")
self.find('//*[@id="adminForm"]/table/tbody/tr[1]/td[3]/b/a')
time.sleep(5)
self.information_name('order_subtotal','200')
self.find_css(save_close)
driver.quit()
def Clients_check_Add(self):
'Add Clients'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.Clients_check_Add.__doc__
self.menu_MooZiiCart('Clients')
self.find_css(new)
self.information_name('u_name', ClientsUsername)
self.information_name('email', ClientsEmail)
self.information_name('password', ClientsPassword)
self.information_name('password2', ClientsPassword)
self.Dropdown('usergroup_id',ClientsUsergroup)
self.find_css(save_close)
self.check_file(ClientsUsername)
driver.quit()
def Options_check_Add(self):
'Click Options'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.Options_check_Add.__doc__
self.menu_MooZiiCart('Options')
driver.quit()
def Manufacturers_check_Add(self):
'Add Manufacturers'
driver = self.driver
self.Options()
self.case = self.Manufacturers_check_Add.__doc__
self.find_linktext('Manufacturers')
self.find_css(new)
self.find(Toggle)
self.information_name('name_en-GB', ManufacturersTitle)
self.information_name('alias_en-GB', ManufacturersAlias)
self.information_name('short_description_en-GB', ManufacturersShort_description)
self.information_name('description1', ManufacturersDescription)
self.find_linktext('Description (th)')
self.information_name('name_th-TH', ManufacturersTitle)
self.information_name('alias_th-TH', ManufacturersAlias)
self.information_name('short_description_th-TH', ManufacturersShort_description)
self.find("//*[@id='th-TH-page']/div[1]/table/tbody/tr[4]/td[2]/div/div[2]/div/a")
self.information_name('description2', ManufacturersDescription)
self.find_linktext(Detail)
self.information_name('manufacturer_url', ManufacturersURL)
self.information_name('products_page', ManufacturersAmount_of_products_on_page)
self.information_name('products_row', ManufacturersAmount_of_products_in_row)
self.find_css(save_close)
self.check_file(ManufacturersTitle)
driver.quit()
def Coupons_check_Add(self):
'Add Coupons'
driver = self.driver
self.Options()
self.case = self.Coupons_check_Add.__doc__
self.find_linktext('Coupons')
self.find_css(new)
self.find_css('tr:nth-child(1) input')
self.information_name('coupon_code', CouponsCode)
self.find("//label[%d]/input" % Coupons_type_n)
self.information_name('coupon_value', CouponsValue)
self.information_name('coupon_start_date', CouponsStart_date)
self.information_name('coupon_expire_date', CouponsExpire_date)
self.information_name('for_user_id', Couponsfor_user_id)
self.find_css('tr:nth-child(8) input')
self.find_css(save_close)
self.check_file(CouponsCode)
driver.quit()
def Currencies_check_Add(self):
'Add Currencies'
driver = self.driver
self.Options()
self.case = self.Currencies_check_Add.__doc__
self.find_linktext('Currencies')
self.find_css(new)
self.find_css('tr:nth-child(1) input')
self.information_name('currency_name', Currencies_Title)
self.information_name('currency_code', Currencies_Code)
self.information_name('currency_code_iso', Code_ISO)
self.information_name('currency_code_num', Code_Numeric)
self.information_name('currency_value', Course_of_exchange)
self.find_css(save_close)
self.check_file(Currencies_Title)
driver.quit()
def Bank_check_Add(self):
'Add Bank'
driver = self.driver
self.Options()
self.case = self.Bank_check_Add.__doc__
self.find_linktext('Bank')
self.find_css(new)
self.information_name('bank_code', Bank_Code)
self.information_name('bank_name', Bank_Name)
self.find_css(save_close)
self.check_file(Bank_Name)
driver.quit()
def Taxes_check_Add(self):
'Add Taxes'
driver = self.driver
self.Options()
self.case = self.Taxes_check_Add.__doc__
self.find_linktext('Taxes')
self.find_css(new)
self.information_name('tax_name', Tax_Title)
self.information_name('tax_value', Tax_Value)
self.find_css(save_close)
self.find("//tr[%d]/td[4]/a" % Extended_rule_tax)
self.find_css(new)
self.Dropdown('tax_id', List_of_tax_rules_Title)
self.find_css("option[value='%s']" % List_of_tax_rules_Country)
self.information_name('tax', Tax)
self.information_name('firma_tax', Company_tax)
self.find_css(save_close)
self.check_file(Tax_Title)
driver.quit()
def Payment_check_Add(self):
'Add Payment'
driver = self.driver
self.Options()
self.case = self.Payment_check_Add.__doc__
self.find_linktext('Payments')
self.find_css(new)
self.find_css("tr:nth-child(1) input")
self.information_name('name_en-GB', Title_Payment)
self.information_name('name_th-TH', Title_Payment)
self.information_name('payment_class', Alias_Payment)
self.Dropdown('tax_id', Please_select_tax_Payment)
self.find_css(save_close)
self.check_file(Title_Payment)
driver.quit()
def Shipping_methods_check_Add(self):
'Add Shipping methods'
driver = self.driver
self.Options()
self.case = self.Shipping_methods_check_Add.__doc__
self.find_linktext('Shipping methods')
self.find_css(new)
self.find_css("tr:nth-child(1) input")
self.information_name('name_en-GB', Title_Shipping)
self.information_name('name_th-TH', Title_Shipping)
self.find_css(save_close)
self.find_css(".button-cog")
self.find_css(".btn-small")
self.find("//tr[%d]/td[4]/a"% Delivery_methods_prices)
self.find_css(new)
self.find_css("#shipping_countries_id > option:nth-child(%d)"%Country_Shipping)
self.information_name('shipping_stand_price', Price_Shipping)
self.Dropdown('shipping_tax_id', Tax_Shipping)
self.information_name('package_stand_price', Package_Price_Shipping)
self.Dropdown('package_tax_id', Package_Tax_Shipping)
self.find_css(save_close)
self.check_file(Title_Shipping)
driver.quit()
def Delivery_time_check_Add(self):
'Add Delivery time'
driver = self.driver
self.Options()
self.case = self.Delivery_time_check_Add.__doc__
self.find_linktext('Delivery time')
self.find_css(new)
self.information_name('name_en-GB', Title_en)
self.information_name('name_th-TH', Title_th)
self.information_name('days', Days)
self.find_css(save_close)
self.check_file(Title_en)
driver.quit()
def Order_status_check_Add(self):
'Add Order status'
driver = self.driver
self.Options()
self.case = self.Order_status_check_Add.__doc__
self.find_linktext('Order status')
self.find_css(new)
self.information_name('name_en-GB', status_Title_en)
self.information_name('name_th-TH', status_Title_th)
self.information_name('status_code', status_Code)
self.find_css(save_close)
self.check_file(status_Title_en)
driver.quit()
def Country_check_Add(self):
'Add Country list'
driver = self.driver
self.Options()
self.case = self.Country_check_Add.__doc__
self.find_linktext('Country list')
self.find_css(new)
self.find_css('tr:nth-child(1) input')
self.information_name('name_en-GB', Country_Title_en)
self.information_name('name_th-TH', Country_Title_th)
self.information_name('country_code', Country_Code)
self.information_name('country_code_2', Country_Code2)
self.find_css(save_close)
self.check_file(Country_Title_en)
driver.quit()
def Province_check_Add(self):
'Add Province'
driver = self.driver
self.Options()
self.case = self.Province_check_Add.__doc__
self.find_linktext('Province')
self.find_css(new)
self.information_name('PROVINCE_CODE', Province_Code)
self.information_name('PROVINCE_NAME_en-GB', Province_Name_en)
self.information_name('PROVINCE_NAME_th-TH', Province_Name_th)
self.find_css(save_close)
self.Dropdown('list[limit]', 'All')
self.check_file(Province_Name_en)
driver.quit()
def Amphur_check_Add(self):
'Add Amphur'
driver = self.driver
self.Options()
self.case = self.Amphur_check_Add.__doc__
self.find_linktext('Amphur')
self.find_css(new)
self.find_css('a.chzn-single > span')
self.find_css('.active-result:nth-child(%s)' % ProvinceName)
# self.find("//li[%s]" % ProvinceName)
self.information_name('AMPHUR_CODE', AmphurCode)
self.information_name('AMPHUR_NAME_en-GB', AmphurName_en)
self.information_name('AMPHUR_NAME_th-TH', AmphurName_th)
self.information_name('POSTCODE', Postcode)
self.find_css(save_close)
self.Dropdown('list[limit]', 'All')
self.check_file(AmphurName_en)
driver.quit()
def District_check_Add(self):
'Add District'
driver = self.driver
self.Options()
self.case = self.District_check_Add.__doc__
self.find_linktext('District')
self.find_css(new)
self.find_css('a.chzn-single > span')
self.find_css('.active-result:nth-child(%s)' % District_ProvinceName)
# self.find("//li[%s]" % District_ProvinceName)
time.sleep(5)
self.find_css("#AMPHUR_ID_chzn span")
# self.find_css('.result-selected:nth-child(%d)' % District_AmphurName)
self.xpath_click("//tr[2]/td[2]/div/div/ul/li[%s]" % District_AmphurName)
# self.driver.find_element_by_xpath("//tr[2]/td[2]/div/div/ul/li[%s]" % District_AmphurName).click()
# self.find("//tr[2]/td[2]/div/div/ul/li[%s]" % District_AmphurName)
self.information_name('DISTRICT_CODE', Districtcode)
self.information_name('DISTRICT_NAME_en-GB', DistrictName_en)
self.information_name('DISTRICT_NAME_th-TH', DistrictName_th)
self.find_css(save_close)
self.Dropdown('list[limit]', 'All')
self.check_file(DistrictName_en)
driver.quit()
def Attributes_check_Add(self):
'Add Attributes'
driver = self.driver
self.Options()
self.case = self.Attributes_check_Add.__doc__
self.find_linktext('Attributes')
self.find_css(new)
self.information_name('name_en-GB', Attributes_Title_en)
self.information_name('name_th-TH', Attributes_Title_th)
self.Dropdown('attr_type', Type)
element1 = self.driver.find_element_by_id("independent0")
element2 = self.driver.find_element_by_id("1")
self.driver.execute_script("arguments[%s].click();" % Dependent, element1, element2)
element3 = self.driver.find_element_by_name("allcats")
element4 = self.driver.find_element_by_id("allcats0")
self.driver.execute_script("arguments[%s].click();" % Show_for_categories, element3, element4)
if Show_for_categories == "1":
self.find_css("option:nth-child(%s)" % category_No)
self.find_css(save_close)
self.check_file(Attributes_Title_en)
driver.quit()
def Free_attributes_check_Add(self):
'Add Free attributes'
driver = self.driver
self.Options()
self.case = self.Free_attributes_check_Add.__doc__
self.find_linktext('Free attributes')
self.find_css(new)
self.information_name('name_en-GB', Free_attributes_Title_en)
self.information_name('name_th-TH', Free_attributes_Title_th)
self.information_name('description_en-GB', Free_attributes_description_en)
self.information_name('description_th-TH', Free_attributes_description_th)
self.find_css('input:nth-child(2)')
self.find_css(save_close)
self.check_file(Free_attributes_Title_en)
driver.quit()
def Units_of_measure_check_Add(self):
'Units of measure'
driver = self.driver
self.Options()
self.case = self.Units_of_measure_check_Add.__doc__
self.find_linktext('Units of measure')
self.find_css(new)
self.information_name('name_en-GB', unit_en)
self.information_name('name_th-TH', unit_th)
self.find_css(save_close)
self.check_file(unit_en)
driver.quit()
def User_groups_check_Add(self):
'Add User groups'
driver = self.driver
self.Options()
self.case = self.User_groups_check_Add.__doc__
self.find_linktext('User groups')
self.find_css(new)
self.information_name('name_en-GB', Usergroups_Title_en)
self.information_name('name_th-TH', Usergroups_Title_th)
self.information_name('usergroup_discount', Discount)
self.find(Toggle)
self.information_name('description1', Description_en)
self.find("//form[@id='adminForm']/div/fieldset/table/tbody/tr[7]/td[2]/div/div[2]/div/a")
self.information_name('description2', Description_th)
self.find_css(save_close)
self.check_file(Usergroups_Title_en)
driver.quit()
def Product_comments_check_Add(self):
'Add Product comments'
driver = self.driver
self.Options()
self.case = self.Product_comments_check_Add.__doc__
self.find_linktext('Product comments')
self.find_css(new)
self.information_name('product_id', prodoct_ID)
self.information_name('user_name', Productuser)
self.information_name('user_email', Productemail)
self.information_name('review', comment)
self.find_css(save_close)
time.sleep(5)
driver.quit()
def Product_labels_check_Add(self):
'Add Product labels'
driver = self.driver
self.Options()
self.case = self.Product_labels_check_Add.__doc__
self.find_linktext('Product labels')
self.find_css(new)
self.information_name('name_th-TH', name_th)
self.information_name('name_en-GB', name_en)
self.find_css(save_close)
self.check_file(name_en)
driver.quit()
def Product_Characteristics_check_Add(self):
'Add Product Characteristics'
driver = self.driver
self.Options()
self.case = self.Product_Characteristics_check_Add.__doc__
self.find_linktext('Product Characteristics')
self.find_css(new)
self.information_name('name_en-GB', P_C_Title_en)
self.information_name('name_th-TH', P_C_Title_th)
self.information_name('description_en-GB', P_C_description_en)
self.information_name('description_th-TH', P_C_description_th)
self.find_css(P_C_Show_categories)
if P_C_Show_categories == '#allcats0':
self.find_css('#category_id > option:nth-child(%d)' % P_C_categories)
self.find_css(Type_List)
self.find_css(save_close)
self.check_file(P_C_Title_en)
driver.quit()
def Languages_check_Add(self):
'check Languages'
driver = self.driver
self.Options()
self.case = self.Languages_check_Add.__doc__
self.find_linktext('Languages')
self.box(1, 2)
self.box(2, 2)
self.find_css(Unpublic)
self.box(1, 2)
self.box(2, 2)
self.find_css(Public)
driver.quit()
def Import_Export_check_Add(self):
'Add Import & Export'
driver = self.driver
self.Options()
self.case = self.Import_Export_check_Add.__doc__
self.find_linktext('Import & Export')
self.find("//a[contains(.,'%s')]" % file)
self.information_name('params[filename]', file_name)
self.find_css(save_close)
self.find("//a[contains(.,'%s')]" % file)
self.check_file(file_name)
driver.quit()
def Addons_check_Add(self):
'Add Addons'
driver = self.driver
self.Options()
self.case = self.Addons_check_Add.__doc__
self.find_linktext('Addons')
driver.quit()
def Statistic_check_Add(self):
'check Statistic'
driver = self.driver
self.Options()
self.case = self.Statistic_check_Add.__doc__
self.find_linktext('Statistic')
time.sleep(4)
driver.quit()
def About_us_check_Add(self):
'Click About us check'
driver = self.driver
self.openwed_Login(pw1,self.base_url,self.username,self.pwd)
self.case = self.About_us_check_Add.__doc__
self.menu_MooZiiCart('About us')
driver.quit()
def Create_Account_check_Add(self):
'Add Create_Account'
driver = self.driver
self.driver.get(wed1)
self.case = self.Create_Account_check_Add.__doc__
self.find_linktext('Create an account')
self.information_name('jform[name]',cneme)
self.information_name('jform[username]',cusername)
self.information_name('jform[password1]',cpassword)
self.information_name('jform[password2]',cpassword)
self.information_name('jform[email1]',cemail)
self.information_name('jform[email2]',cemail)
self.find_css('.validate')
driver.quit()
def Home_Category_check_Add(self):
'Click Category'
driver = self.driver
self.openwed_Login(pw2,wed1,user2,password2)
self.find_linktext('Shop')
self.case = self.Home_Category_check_Add.__doc__
self.find_linktext(Category)
driver.quit()
def Home_Product_check_Add(self):
'Click Product'
driver = self.driver
self.openwed_Login(pw2,wed1,user2,password2)
self.find_linktext('Shop')
self.find_linktext(Category)
self.case = self.Home_Product_check_Add.__doc__
self.find_linktext(Product)
driver.quit()
def Home_Cart_check_Add(self):
'Cart'
driver = self.driver
driver.get(wed1)
self.find_linktext('Shop')
self.find_linktext(Category)
# self.find_linktext(Product)
# self.find_css('.btn-buy')
self.case = self.Home_Cart_check_Add.__doc__
self.menu_buy(1)
self.find_css(Back_to_shop)
self.menu_buy(2)
self.information_name('quantity[0]', '2')
self.information_name('quantity[1]', '2')
self.find_css(Update_cart)
self.information_css(information_css,"300")
self.find_css(Activate)
self.find("(//img[@alt='Delete'])[%d]" % Delete)
self.Confirm()
self.find_linktext('Checkout')
self.information_name('username',user2)
self.information_css('#jlpassword',password2)
self.find_css('.button')
self.Dropdown('title',Title)
self.information_name('f_name', First_name)
self.information_name('l_name', Last_name)
self.information_name('email',Email)
self.information_name('street', Street_No)
self.information_name('zip', Postal_Code)
self.information_name('city', City)
self.Dropdown('country',Country)
self.information_name('phone',phone)
self.find_css('.button')
self.find_css('#payment_method_%d' % payment)
self.find_css('.button')
self.find_css(Standard)# Standard , Express
self.find_css('.button')
self.find_css('#agb')
self.find_css('.button')
time.sleep(5)
driver.quit()
class test01_check_Add(MooZiiCart_check):
def test01(self):
self.categories_check_Add()
[/code]