class RestaurantSeed: def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.receivingAssert = ReceivingAssert(self.html, self.driver) def createTable(self, tableName, tableShape='Kör', tableType='Normál', discount='0', module=False): if module: self.menu.openTableMapEditor() self.html.clickElement(tableShape + ' asztal hozzáadása', 'a', Options(htmlAttribute='title')) self.html.refresh() self.html.clickElement('Étterem', 'i') self.html.fillInput('Asztal neve', tableName) if not tableType == 'Normál': self.html.clickDropdown('Asztal típusa', tableType) if tableType == 'Főnöki' or tableType == 'Személyzeti': self.html.fillInput('Kedv.', discount) self.html.clickElement( 'Rögzít', 'span' ) # Span-t kell használni mert valamiért 'Rögzít' buttonból van egy amit előbb megtalál és az nem interactable def deleteTable(self, tableName, module=False): if module: self.menu.openTableMapEditor() self.html.clickElement(tableName, 'i') self.html.clickElement( 'Törlés', 'span') # ugyan az az állás mint a fenti kommentnél self.html.clickElement('Igen') def createDynamicCourierTable(self, name): self.html.clickElement('+', waitSeconds=1) self.html.fillAutocomplete('cl_name', 'input', name, name, 'li', options=Options(htmlAttribute='id')) self.html.clickElement('Rögzít', 'span')
def setUpClass(self): chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--window-size=1920,1080') # chrome_options.add_argument("--auto-open-devtools-for-tabs") #chrome_options.add_argument('--disable-gpu') #chrome_options.headless = True self.driver = webdriver.Chrome( executable_path='C:/webdrivers/chromedriver.exe', options=chrome_options) self.driver.delete_all_cookies() self.driver.maximize_window() config = read_section() self.driver.get(config.get('path')) self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.stockseed = StockSeed(self.driver) self.productseed = ProductSeed(self.driver) self.receivingseed = ReceivingSeed(self.driver) self.restaurantseed = RestaurantSeed(self.driver) self.clientseed = ClientSeed(self.driver) self.usersSeed = UsersSeed(self.driver) self.stockAssert = StockAssert(self.html, self.driver) self.productAssert = ProductAssert(self.html, self.driver) self.receivingAssert = ReceivingAssert(self.html, self.driver) self.restaurantAssert = RestaurantAssert(self.html, self.driver) self.clientAssert = ClientManagementAssert(self.html, self.driver) self.usersAssert = UserAssert(self.html, self.driver) self.result = unittest.TestResult
class ReceivingSeed(): def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.receivingAssert = ReceivingAssert(self.html, self.driver) def createPartner(self, name, id, module=False, tab=False): if module: self.menu.openReceiving() self.html.clickElement('Beszállítók', 'a') if tab: self.html.clickElement('Beszállítók', 'a') self.html.clickElement('Új beszállító', 'a') self.html.switchFrame('iframe') self.html.fillInput('Beszállító neve', name) self.html.fillInput('Belső azonosító', id) self.html.clickElement('Rögzít') self.html.switchFrame() self.receivingAssert.assertPartnerExist(name, 'Beszállítók') def deleteParter(self, partnerName, module=False, tab=False): if module: self.menu.openReceiving() self.html.clickElement('Beszállítók', 'a') if tab: self.html.clickElement('Beszállítók', 'a') self.html.search(partnerName, 'Beszállítók') self.html.clickElement( None, '//table[@id="partners"]//tr[contains(.,"' + partnerName + '")]//label', Options(uniqueSelector=True)) self.html.clickElement('deletePartners', options=Options(htmlAttribute='id')) self.html.clickElement('Igen') self.html.refresh() self.receivingAssert.assertPartnerNotExist(partnerName, 'Beszállítók')
def __init__(self, htmlProxy, driver): super().__init__() self.html = htmlProxy self.menu = MainMenuProxy(driver)
def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.stockAssert = StockAssert(self.html, self.driver)
class StockSeed: def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.stockAssert = StockAssert(self.html, self.driver) def createRawMaterial(self, materialName, me, wareHouse, module=False): if module: self.menu.openStocks() self.html.clickElement('Új nyersanyag felvitele', 'a') self.html.switchFrame('iframe') self.html.fillInput('Nyersanyag neve', materialName) self.html.clickDropdown('ME', me) self.html.clickDropdown('Raktár', wareHouse) self.html.clickElement('Rögzít') self.html.switchFrame() self.html.refresh() self.stockAssert.assertMaterialExist(materialName, 'Raktárkészlet') def createRawMaterialWithOpening(self, testName, grossPrice, openingQty, whName, me='liter', module=False): if module: self.menu.openStocks() self.html.clickElement('Új nyersanyag felvitele', 'a') self.html.switchFrame('iframe') self.html.fillInput('Nyersanyag neve', testName) self.html.fillInput('Bruttó beszerzési egységár', grossPrice) self.html.clickDropdown('ME', me) self.html.fillInput('Nyitó mennyiség', openingQty) self.html.clickDropdown('Raktár', whName) self.html.clickElement('Rögzít') self.html.switchFrame() def deleteRawMaterial(self, name, module=False): if module: self.menu.openStocks() self.html.wait(2) self.html.search(name, 'Raktárkészlet') self.html.wait(2) self.html.clickTableDropdown(name, 'Törlés', 'Raktárkészlet') self.html.wait(2) self.html.clickElement('Igen') self.html.wait(2) self.html.search('', 'Raktárkészlet') self.html.wait(2) def createWarehouse(self, warehouseName, module=False, tab=False): if module: self.menu.openStocks() self.html.clickElement('Raktárak', 'a') elif tab: self.html.clickElement('Raktárak', 'a') self.html.clickElement('Új raktár felvitele', 'a') self.html.switchFrame('iframe') self.html.fillInput('Raktár neve', warehouseName) self.html.clickElement('Rögzít') self.html.switchFrame() def deleteWarehouse(self, warehouseName, module=False, tab=False): if module: self.menu.openStocks() self.html.clickElement('Raktárak', 'a') elif tab: self.html.clickElement('Raktárak', 'a') self.html.refresh() self.html.wait(2) self.html.search(warehouseName, 'Raktárak') self.html.wait(2) currWindow = self.html.getElement('tabs-3', 'div', options=Options(htmlAttribute='id')) # itt azert adjuk at a currWindow-t, hogy az adott oldalon keressen a td-k kozott self.html.clickElement(warehouseName, 'td', Options(following='a', element=currWindow)) self.html.wait(3) self.html.clickElement('Igen') self.html.wait(2) self.html.search('', 'Raktárak') self.html.wait(2)
class ProductSeed: def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.stockAssert = StockAssert(self.html, self.driver) def createProductGroup(self, groupName, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Termékcsoportok', 'a') if tab: self.html.clickElement('Termékcsoportok', 'a') self.html.clickElement('Új termékcsoport felvitele', 'a') self.html.switchFrame('iframe') self.html.fillInput('Termékcsoport neve', groupName) self.html.clickDropdown('Kategória', 'Étel') self.html.clickElement('Rögzít') self.html.wait(12) self.html.switchFrame() self.html.wait(5) def deleteProductGroup(self, groupName, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Termékcsoportok', 'a') elif tab: self.html.clickElement('Termékcsoportok', 'a') self.html.clickTableElement('product_groups', 'id', groupName, 'span', 'Törlés', 'Termékcsoportok') self.html.wait(2) self.html.clickElement('Igen') def createMenu(self, menuName, firstMeal, secondMeal, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Menü', 'a') elif tab: self.html.clickElement('Menü', 'a') self.html.clickElement('Új menü felvitele', 'a') self.html.switchFrame('iframe') self.html.clickDropdown('Nyomtatási részleg', 'Konyha') self.html.fillInput('Termék neve', menuName) self.html.getElement( 'Termékcsoport', 'label', Options(following='input//following::input')).click() self.html.wait(2) self.html.switchFrame('iframe') self.html.clickElement('Ételek', 'a') self.html.clickElement('Rögzít') self.html.switchFrame('iframe') self.html.fillInput('Kód', '1212') self.html.getElement('27%', 'td', Options(following='td//input')).send_keys('100') self.html.fillInput('Fogás neve', 'Előétel') self.html.clickDropdown('Termékcsoport:', td.ProductGroup['Egyeb']['Name']) self.html.clickElement(td.ProductGroup['Egyeb']['Name']) self.html.fillInput('Mennyiség', '1') self.html.getInput('Mennyiség', 'label').click() self.html.clickElement('Hozzáad') self.html.wait(3) self.html.clickElement(firstMeal, 'span') self.html.clickElement('icon-hozzaadas addNewComponent', 'i', Options(htmlAttribute='class')) self.html.wait(3) tab = self.html.getElement('tabs-2', 'div', Options(htmlAttribute='id')) self.html.fillInput('Fogás neve', 'Főétel', options=Options(element=tab)) self.html.clickDropdown('Termékcsoport:', td.ProductGroup['Egyeb']['Name'], options=Options(element=tab)) self.html.clickElement(td.ProductGroup['Egyeb']['Name'], options=Options(element=tab)) self.html.fillInput('Mennyiség', '1', options=Options(element=tab)) self.html.getInput('Mennyiség', 'label', options=Options(element=tab)).click() self.html.clickElement('Hozzáad', options=Options(element=tab)) self.html.wait(3) self.html.clickElement(secondMeal, 'span', options=Options(element=tab)) self.html.clickElement('Rögzít') self.html.switchFrame() def deleteMenu(self, menuName, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Menü', 'a') elif tab: self.html.clickElement('Menü', 'a') self.html.clickTableElement('menu', 'id', menuName, 'span', 'Törlés', 'Menü') self.html.clickElement('Igen') def createPizza(self, pizzaName, baseComponent, topping, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Pizza (testreszabható)', 'a') elif tab: self.html.clickElement('Pizza (testreszabható)', 'a') self.html.clickElement('Új pizza (testreszabható)', 'a') self.html.switchFrame('iframe') self.html.clickDropdown('Nyomtatási részleg', 'Pizza') self.html.fillInput('Termék neve', pizzaName) self.html.fillInput('Kód', '1211') self.html.clickDropdown('Szósz', 'Paradicsomos alap') self.html.fillAutocomplete('baseComponentName', 'input', baseComponent, baseComponent, 'li', Options(htmlAttribute='id')) table = self.html.getElement('baseComponents', 'table', Options(htmlAttribute='id')) self.html.getElement('Hozzáad', 'button', Options(element=table)).click() # self.html.fillAutocomplete('toppingComponentName', 'input', topping, topping, 'li', Options(htmlAttribute='id')) # table = self.html.getElement('toppingComponents', 'table', Options(htmlAttribute='id')) # self.html.getElement('Hozzáad', 'button', element=table).click() self.html.clickElement('Mennyiségek', 'a') self.html.wait(2) td = self.html.getElement('Eladási ár(ak)', 'td') self.html.clickElement('edit actionButton fright editPriceBtn', 'a', Options(htmlAttribute='class')) self.html.fillInput('Nettó', '1000') self.html.wait(2) self.html.clickElement('Rögzít', 'a', waitSeconds=2) #self.html.closeAllert() #self.html.clickElement('Rögzít', 'a') self.html.clickElement('Rögzít') def deletePizza(self, pizzaName, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Pizza (testreszabható)', 'a') elif tab: self.html.clickElement('Pizza (testreszabható)', 'a') self.html.clickTableElement('customproduct-2', 'id', pizzaName, 'a', 'Törlés', 'Pizza (testreszabható)') self.html.clickElement('Igen') def createProduct(self, name, group, code, counter, component, compQty=2, netPrice=100, module=False): if module: self.menu.openProducts() self.html.clickElement('Új termék felvitele', 'a') self.html.switchFrame('iframe') self.html.clickDropdown('Nyomtatási részleg', 'Pult') self.html.switchFrame('iframe') self.html.clickElement(group, 'a') self.html.clickElement('Rögzít') self.html.switchFrame('iframe') self.html.fillInput('Termék neve', name) self.html.fillInput('Kód', code) self.html.clickElement('p_counters', 'input', Options(htmlAttribute='id'), waitSeconds=1) self.html.switchFrame('iframe') self.html.clickElement(counter, 'td') self.html.clickElement('Rögzít') self.html.switchFrame('iframe') places = self.html.getElement('Eladási ár (Kötelező)', 'td') self.html.clickElement('Ár megadása', options=Options(element=places)) self.html.fillInput('Nettó', netPrice) self.html.wait(1) self.html.clickElement('taxPriceSave', 'a', options=Options(htmlAttribute='id')) self.html.wait(2) self.html.fillAutocomplete('componentName', 'input', component, component, 'li', Options(htmlAttribute='id')) self.html.fillInput('componentQty', compQty, 'input', options=Options(htmlAttribute='id')) self.html.clickElement('Hozzáad') self.html.clickElement('Rögzít') def createProductConveniencies(self, name, group, code, counter, component, compQty=2, module=False): if module: self.menu.openProducts() self.html.clickElement('Új termék felvitele', 'a') self.html.switchFrame('iframe') self.html.clickDropdown('Nyomtatási részleg', 'Pult') self.html.switchFrame('iframe') self.html.clickElement(group, 'a') self.html.clickElement('Rögzít') self.html.switchFrame('iframe') self.html.fillInput('Termék neve', name) self.html.fillInput('Kód', code) self.html.clickElement('p_counters', 'input', Options(htmlAttribute='id'), waitSeconds=1) self.html.switchFrame('iframe') self.html.clickElement(counter, 'td') self.html.clickElement('Rögzít') self.html.switchFrame('iframe') self.html.clickElement( None, './/label[contains(.,"Gyártás termék") and @class="radio formStyle"]', options=Options(uniqueSelector=True)) self.html.fillInput('Recept adag', '1') self.html.fillAutocomplete('componentName', 'input', component, component, 'li', Options(htmlAttribute='id')) self.html.fillInput('componentQty', compQty, 'input', options=Options(htmlAttribute='id')) self.html.clickElement('Hozzáad') self.html.clickElement('Rögzít') def deleteProduct(self, name, module=False): if module: self.menu.openProducts() self.html.refresh() self.html.clickTableElement('products', 'id', name, 'a', 'Törlés', 'Termékek') self.html.clickElement('Igen', waitSeconds=2) self.html.search('', 'Termékek') def createCounter(self, name, position, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Számlálók', 'a') if tab: self.html.clickElement('Számlálók', 'a') self.html.clickElement('Új számláló felvitele', 'a') self.html.switchFrame('iframe') self.html.fillInput('Számláló neve', name) self.html.fillInput('Számláló állás', position) self.html.clickElement('Rögzít') self.html.switchFrame() def deleteCounter(self, name, module=False, tab=False): if module: self.menu.openProducts() self.html.clickElement('Számlálók', 'a') if tab: self.html.clickElement('Számlálók', 'a') self.html.refresh() self.html.clickTableElement('counters', 'id', name, 'a', 'Törlés', 'Számlálók') self.html.clickElement('Igen', waitSeconds=1) self.html.search('', 'Számlálók')
def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.receivingAssert = ReceivingAssert(self.html, self.driver)
def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.usersAssert = UserAssert(self.html, self.driver)
class StockAssert(unittest.TestCase): def __init__(self, htmlProxy, driver): super().__init__() self.html = htmlProxy self.menu = MainMenuProxy(driver) self.cg = cg() def assertWarehouseExist(self, name, tab): self.assertTrue( self.html.getElementInTable(name, 'storages', tab).is_displayed()) def assertWarehouseNotExist(self, name, tab): with self.assertRaises(NoSuchElementException): self.html.getElementInTable(name, 'storages', tab) def assertDialogDisplayed(self): self.assertTrue( self.html.getElement( 'iframe', 'body', Options(htmlAttribute='class')).is_displayed()) def assertMaterialExist(self, materialName, tab): self.html.search(materialName, tab) self.assertTrue( self.html.getElement(materialName, 'td').is_displayed()) self.html.search('', tab) #self.assertTrue(self.html.getElementInTable(materialName, 'td', tab).is_displayed()) def assertAllergenExist(self, allergenName): self.assertTrue( self.html.getElement(allergenName, 'td').is_displayed()) def assertStockMovementExist(self, fromWh, toWh): self.assertTrue(self.html.getElement(fromWh, 'td').is_displayed()) self.assertTrue(self.html.getElement(toWh, 'td').is_displayed()) def assertStock(self, materialName, whName, qty): tab = 'Raktárkészlet' self.menu.openStocks() self.html.clickTableDropdown(materialName, 'Raktárak', tab) self.html.switchFrame('iframe') if qty != '0': stock = self.html.getElement( whName, 'td', Options(following='td//following::td')).text self.assertEqual(stock, qty) else: with self.assertRaises(NoSuchElementException): self.html.getElement(whName, 'td') self.html.switchFrame() self.html.clickElement('Close', 'a', Options(htmlAttribute='title')) self.html.clickTableDropdown(materialName, 'Készlet', tab) self.html.switchFrame('iframe') if qty != '0': stock = self.html.getElement( whName, 'td', Options(following='td//following::td')).text self.assertEqual(stock, qty) else: with self.assertRaises(NoSuchElementException): self.html.getElement(whName, 'td') self.html.switchFrame() self.html.clickElement('Close', 'a', Options(htmlAttribute='title')) self.html.clickElement('Raktárak', 'a') self.html.search(whName, 'Raktárak') self.html.clickElement( None, "//tr[contains(., '" + whName + "')]//a[contains(@class, 'stock') and contains(@class, 'actionButton')]", Options(uniqueSelector=True)) self.html.switchFrame("iframe") if qty != '0': stock = self.html.getElement(materialName, 'td', Options(following='td')).text self.assertEqual(stock, qty) else: with self.assertRaises(NoSuchElementException): self.html.getElement(materialName, 'td') self.html.switchFrame() self.html.clickElement('Close', 'a', Options(htmlAttribute='title')) self.menu.openStocks() def assertDeletedMaterial(self, materialName, whName): self.html.clickElement('Raktárak', 'a') self.html.search(whName, 'Raktárak') self.html.clickElement( None, "//tr[contains(., '" + whName + "')]//a[contains(@class, 'stock') and contains(@class, 'actionButton')]", Options(uniqueSelector=True)) self.html.switchFrame("iframe") with self.assertRaises(NoSuchElementException): self.html.getElement(materialName, 'td') self.html.switchFrame() self.html.clickElement('Close', 'a', Options(htmlAttribute='title')) self.menu.openStocks()
def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.clientAssert = ClientManagementAssert(self.html, self.driver)
class ClientSeed: def __init__(self, driver): self.driver = driver self.html = HtmlProxy(self.driver) self.menu = MainMenuProxy(self.driver) self.clientAssert = ClientManagementAssert(self.html, self.driver) def createClient(self, name, code, phone, discount, taxnumber, country, postalCode, city, street, houseNumber, tab=False): if tab: self.html.clickElement('Házhozszállítási cím', 'a') self.html.clickElement('Új házhozszállítási cím', 'a', waitSeconds=2) self.html.switchFrame('iframe') self.html.fillInput('Név / azonosító', name) self.html.fillInput('Ügyfélazonosító', code) self.html.fillInput('Telefon', phone) self.html.fillInput('Kedv. (%)', discount) self.html.fillInput('Adószám', taxnumber) self.html.fillInput('ca_country_helper', country, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_zip_helper', postalCode, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_city_helper', city, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_street_helper', street, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_housenumber_helper', houseNumber, 'input', options=Options(htmlAttribute='id')) self.html.clickElement('Hozzáad') self.html.clickElement('Rögzít', waitSeconds=2) self.html.switchFrame() address = country + ', ' + postalCode + ' ' + city + ' ' + street + ' ' + houseNumber return address def createRegular(self, name, code, phone, discount, taxnumber, country, postalCode, city, street, houseNumber, module=False, tab=False): if module: self.menu.openClientManagement() self.html.clickElement('Törzsvendégek', 'a') if tab: self.html.clickElement('Törzsvendégek', 'a') self.html.clickElement('Új törzsvendég', 'a', waitSeconds=2) self.html.switchFrame('iframe') self.html.fillInput('Név / azonosító', name) self.html.fillInput('Ügyfélazonosító', code) self.html.fillInput('Telefon', phone) self.html.fillInput('Kedv. (%)', discount) self.html.fillInput('Adószám', taxnumber) self.html.fillInput('ca_country_helper', country, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_zip_helper', postalCode, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_city_helper', city, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_street_helper', street, 'input', options=Options(htmlAttribute='id')) self.html.fillInput('ca_housenumber_helper', houseNumber, 'input', options=Options(htmlAttribute='id')) self.html.clickElement('Hozzáad') self.html.clickElement('Rögzít', waitSeconds=2) self.html.switchFrame() address = country + ', ' + postalCode + ' ' + city + ' ' + street + ' ' + houseNumber return address def deleteRegular(self, name, module=False, tab=False): if module: self.menu.openClientManagement() self.html.clickElement('Törzsvendégek', 'a') elif tab: self.html.clickElement('Törzsvendégek', 'a') self.html.wait(2) self.html.search(name, 'Törzsvendégek') self.html.wait(2) self.html.clickTableElement('frequenters', 'id', name, 'a', 'Törlés') self.html.wait(2) self.html.clickElement('Igen') self.html.wait(2) self.html.search('', 'Törzsvendégek') self.html.wait(2) def deleteCard(self, name, module=False, tab=False): if module: self.menu.openClientManagement() self.html.clickElement('Kedvezménykártyák', 'a') elif tab: self.html.clickElement('Kedvezménykártyák', 'a') self.html.wait(2) self.html.search(name, 'Kedvezménykártyák') self.html.wait(2) self.html.clickTableElement('discount_cards', 'id', name, 'a', 'Törlés') self.html.wait(2) self.html.clickElement('Igen') self.html.wait(2) self.html.search('', 'Kedvezménykártyák') self.html.wait(2) def deleteClient(self, name, module=False, tab=False): if module: self.menu.openClientManagement() self.html.clickElement('Házhozszállítási cím', 'a') elif tab: self.html.clickElement('Házhozszállítási cím', 'a') self.html.wait(2) self.html.search(name, 'Házhozszállítási cím') self.html.wait(2) self.html.clickTableElement('frequenters', 'id', name, 'a', 'Törlés') self.html.wait(2) self.html.clickElement('Igen') self.html.wait(2) self.html.search('', 'Törzsvendégek') self.html.wait(2)