def test_checkDuplicate21Item(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Remove item?' text1 = 'Are you sure you want to remove this item?' LoginPage.loginAction(self, 'SellerTestpsq', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) SheetsPage.clickDuplicate(self) time.sleep(3) self.assertEqual( len( self.driver.find_elements_by_css_selector( "[data-test-id='remove']")), 42) SheetsPage.closeSheets(self) SheetsPage.openSheets(self) self.assertEqual( len( self.driver.find_elements_by_css_selector( "[data-test-id='remove']")), 40) SheetsPage.deleteItem(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) HelperTestBase.clickYesButton(self)
def test_checkElements(self): url1 = self.base_url + '/inventory-list' url2 = self.base_url + '/shopping-list' url4 = self.base_url + '/inventory-sheet' driver = self.driver driver.get(self.base_url) LoginPage.loginAction(self, 'SellerTestavm', 'Ss123456') time.sleep(3) NavigationMenuPage.clickSellerButton(self) self.assertEqual(url1, HelperTestBase.getURL(self)) SheetsPage.openSheets(self) time.sleep(4) self.assertEqual(url4, HelperTestBase.getURL(self)) ###Check Remove button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='remove']"), True) # Check the pangination elements: self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToFirstPage']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToPreviousPage']"), True) self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='pageCounter']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToNextPage']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToLastPage']"), True) # Check the Save & Exit button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='saveBtn']"), True) # Check the Cancel button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='cancelLink']"), True)
def test_checkDuplicateItemSuccessAndRemove(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Remove item?' text1 = 'Are you sure you want to remove this item?' LoginPage.loginAction(self, 'Bob', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) SheetsPage.clickDuplicate(self) SheetsPage.closeSheets(self) SheetsPage.openSheets(self) SheetsPage.deleteItem(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) HelperTestBase.clickYesButton(self)
def test_checkOpenSheetsAndClose(self): url1 = self.base_url + '/inventory-list' driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Warning:' text1 = 'You have unsaved changes. Discard them?' LoginPage.loginAction(self, 'Bob', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) SheetsPage.clickCreateButton(self) CategoriesMenuPage.clickVegetablesButton(self) ProductEditorPage.selectCategory(self) SheetsPage.closeSheets(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickCancelButton(self) SheetsPage.closeSheets(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) time.sleep(3) self.assertEqual(url1, HelperTestBase.getURL(self))
def test_checkCreateItemSuccessAndRemove(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Error:' text1 = 'Item#1 - You should choose DELIVERY method.' text2 = 'Item#1 - Field TITLE is required. Please, fill it in.' text3 = 'Item#1 - Field SELLING PRICE is required. Please, fill it in.' text4 = 'Item#1 - Field UNITS is required. Please, fill it in.' text5 = 'Item#1 - Field AVAILABLE QUANTITY is required. Please, fill it in.' text6 = 'Item#1 - Field QUANTITY UNITS is required. Please, fill it in.' LoginPage.loginAction(self, 'Bob', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) SheetsPage.clickCreateButton(self) CategoriesMenuPage.clickVegetablesButton(self) ProductEditorPage.selectCategory(self) ##Don't fill out of requarement field, click on Save button=> Error is displayed: SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text2, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ##Fill out only 'Product Item' field, click on Save button=> Error is displayed: SheetsPage.editProductItemField(self, 'Test Item Test') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text3, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ### Fill out not requarement fields Seller Name and Description: SheetsPage.editSellerNameField(self, 'Aist') SheetsPage.editDescription(self, '123 see') ##Don't fill out other requarement fields, click on Save button => Error is displayed: SheetsPage.editPrice(self, '10') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text4, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ##Don't fill out other requarement fields, click on Save button => Error is displayed: SheetsPage.selectUnits(self, 'Carton') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text5, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ##Don't fill out other requarement fields, click on Save button => Error is displayed: SheetsPage.editAvailableQuantity(self, '65') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text6, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.selectQuantityUnits(self, 'Each') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ### Select the not requarement fields Product Code, Sale is Active, Organic, Non GMO : SheetsPage.editProductCode(self, 'New Test String') SheetsPage.selectSaleIsActive(self) SheetsPage.selectOrganic(self) SheetsPage.selectNonGMO(self) SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.selectDeliveryMethod(self) SheetsPage.selectMarketPickUp(self) SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self) SheetsPage.closeSheets(self) ######Return test data: SheetsPage.openSheets(self) SheetsPage.deleteItem(self) HelperTestBase.clickYesButton(self)
def test_checkPangination(self): url1 = self.base_url + '/inventory-list' url2 = self.base_url + '/shopping-list' url4 = self.base_url + '/inventory-sheet' text = '1 / 5' text1 = '2 / 5' text2 = '3 / 5' text3 = '4 / 5' text4 = '5 / 5' driver = self.driver driver.get(self.base_url) LoginPage.loginAction(self, 'SA1', 'Bizibaza111') time.sleep(3) self.assertEqual(url2, HelperTestBase.getURL(self)) NavigationMenuPage.clickSellerButton(self) self.assertEqual(url1, HelperTestBase.getURL(self)) SheetsPage.openSheets(self) time.sleep(4) self.assertEqual(url4, HelperTestBase.getURL(self)) ###Check page counter: self.assertEqual(text, SheetsPage.getPageNumber(self)) ###Check Remove button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='remove']"), True) # Check the pangination elements: self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToFirstPage']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToPreviousPage']"), True) self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='pageCounter']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToNextPage']"), True) self.assertIs( HelperTestBase.checkElementPresent( self, "[data-test-id='goToLastPage']"), True) # Check the Save & Exit button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='saveBtn']"), True) # Check the Cancel button: self.assertIs( HelperTestBase.checkElementPresent(self, "[data-test-id='cancelLink']"), True) # Check the 20 items on the page: # elements = self.driver.find_elements_by_css_selector("[data-test-id='remove']") elements = self.driver.find_elements_by_xpath( "//button[@data-test-id='remove']") self.assertIs(True, elements[0].is_displayed()) self.assertIs(True, elements[19].is_displayed()) # Go to Next page: HelperTestBase.reliableClick(self, "[data-test-id='goToNextPage']") time.sleep(2) self.assertEqual(text1, SheetsPage.getPageNumber(self)) # Go to Next page: HelperTestBase.reliableClick(self, "[data-test-id='goToNextPage']") time.sleep(2) self.assertEqual(text2, SheetsPage.getPageNumber(self)) # Go to Previous page: HelperTestBase.reliableClick(self, "[data-test-id='goToPreviousPage']") time.sleep(2) self.assertEqual(text1, SheetsPage.getPageNumber(self)) # Go to Last page: HelperTestBase.reliableClick(self, "[data-test-id='goToLastPage']") time.sleep(2) self.assertEqual(text4, SheetsPage.getPageNumber(self)) # Go to First page: HelperTestBase.reliableClick(self, "[data-test-id='goToFirstPage']") time.sleep(2) self.assertEqual(text, SheetsPage.getPageNumber(self)) # Check the 20 items on the next page: elements1 = self.driver.find_elements_by_css_selector( "[data-test-id='remove']") self.assertIs(True, elements1[0].is_displayed()) self.assertIs(True, elements1[20].is_displayed())
def test_checkRemoveItemCheck20Items(self): url1 = self.base_url + '/inventory-list' url2 = self.base_url + '/shopping-list' url4 = self.base_url + '/inventory-sheet' text = 'Remove item?' text1 = 'Are you sure you want to remove this item?' x = StringGenerator('[\c]{5}').render() driver = self.driver driver.get(self.base_url) LoginPage.loginAction(self, 'SellerTestcjd', 'Ss123456') time.sleep(3) self.assertEqual(url2, HelperTestBase.getURL(self)) NavigationMenuPage.clickSellerButton(self) self.assertEqual(url1, HelperTestBase.getURL(self)) self.assertEqual( True, HelperTestBase.checkElementPresent( self, "[data-test-id='inventoryItem-0")) self.assertEqual( True, HelperTestBase.checkElementPresent( self, "[data-test-id='inventoryItem-1")) self.assertEqual( True, HelperTestBase.checkElementPresent( self, "[data-test-id='inventoryItem-30")) SheetsPage.openSheets(self) elements = self.driver.find_elements_by_css_selector( "[data-test-id='remove']") self.assertIs(True, elements[0].is_displayed()) self.assertIs(True, elements[19].is_displayed()) SheetsPage.deleteItem(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) HelperTestBase.clickYesButton(self) time.sleep(3) self.assertEqual( len( self.driver.find_elements_by_css_selector( "[data-test-id='remove']")), 38) SheetsPage.closeSheets(self) SheetsPage.openSheets(self) self.assertEqual( len( self.driver.find_elements_by_css_selector( "[data-test-id='remove']")), 40) SheetsPage.closeSheets(self) ProductEditorPage.addProductWithoutYear(self, title='Test Item' + x, description='test' + x, price='1', sortUnits='Each', currentQuantityInp='10', sortQTY='Each', country='Canada', productCodeInp='test', salePrice='1', sortSalePrice='Each') time.sleep(1) HelperTestBase.clickYesButton(self)
def test_checkPriceValidation(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Error:' text1 = 'Item #1 - Unacceptable PRICE value. Must be above zero.' text3 = '$123' text4 = '$54' LoginPage.loginAction(self, 'SellerTestege', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) time.sleep(2) SheetsPage.editPrice(self, '-1') self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editPrice(self, '0') self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editPrice(self, '123#456Afghj') self.assertIn(text3, self.driver.page_source) SheetsPage.editPrice(self, '054') time.sleep(2) self.assertIn(text4, self.driver.page_source) SheetsPage.editPrice(self, '') self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editPrice(self, '<script>alert("xss-injection!")</script>') self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self)
def test_checkValidationFieldsBlocked(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) LoginPage.loginAction(self, 'SellerTestlhc', 'Ss123456') NavigationMenuPage.clickSellerButton(self) # Check that Record field is blocked: SheetsPage.openSheets(self) SheetsPage.clickOnRecordField(self) self.assertEqual( False, hasattr(SheetsPage.clickOnRecordField(self), 'send_keys')) # Check that Category field is blocked: SheetsPage.clickOnCategoryField(self) self.assertEqual( False, hasattr(SheetsPage.clickOnCategoryField(self), 'send_keys')) # Check that SubCategory field is blocker: SheetsPage.clickOnSubCategoryField(self) self.assertEqual( False, hasattr(SheetsPage.clickOnSubCategoryField(self), 'send_keys')) # Check that SubCategoryEntry field is blocked: SheetsPage.clickOnSubCategoryEntryField(self) self.assertEqual( False, hasattr(SheetsPage.clickOnSubCategoryEntryField(self), 'send_keys'))
def test_checkCountryValidation(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) LoginPage.loginAction(self, 'SellerTestege', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) time.sleep(2) SheetsPage.selectCountry(self, text='Canada') SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self) SheetsPage.selectCountry(self, text='Panama') SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self) SheetsPage.selectCountry(self, text='Country') SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self)
def test_checkAvailableQuantityValidation(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'Error:' text6 = 'Item #1 - Unacceptable AVAILABLE QUANTITY value. Must be zero or above.' text1 = 'Item#1 - Field AVAILABLE QUANTITY is required. Please, fill it in.' text5 = 'Incorrect value type for QTYUNITID field.' text7 = 'Item#1 - Field AVAILABLE QUANTITY is required. Please, fill it in.' text3 = '$123' text4 = '543' LoginPage.loginAction(self, 'SellerTestege', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) time.sleep(2) SheetsPage.editAvailableQuantity(self, '-1') self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text6, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editAvailableQuantity(self, '0') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editAvailableQuantity(self, '123#456Afghj') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text7, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editAvailableQuantity(self, '054') SheetsPage.clickSaveButton(self) time.sleep(2) self.assertIn(text4, self.driver.page_source) SheetsPage.editAvailableQuantity(self, '') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) SheetsPage.editAvailableQuantity( self, '<script>alert("xss-injection!")</script>') SheetsPage.clickSaveButton(self) self.assertEqual(text, HelperTestBase.getModalHeader(self)) self.assertEqual(text1, HelperTestBase.getModalMessage(self)) HelperTestBase.clickYesButton(self) ##### Returt test data: SheetsPage.editAvailableQuantity(self, '543') time.sleep(2) self.assertIn(text4, self.driver.page_source)
def test_checkXSSValidation(self): driver = self.driver driver.maximize_window() driver.get(self.base_url) text = 'alert("xss-injection!")' text2 = '<script>' text1 = '<script>alert("xss-injection!")</script>' LoginPage.loginAction(self, 'SellerTestege', 'Ss123456') NavigationMenuPage.clickSellerButton(self) SheetsPage.openSheets(self) time.sleep(2) # Checking on XSS injections : SheetsPage.editProductItemField( self, '<script>alert("xss-injection!")</script>') SheetsPage.editSellerNameField( self, '<script>alert("xss-injection!")</script>') SheetsPage.editDescription(self, '<script>alert("xss-injection!")</script>') SheetsPage.editProductCode(self, '<script>alert("xss-injection!")</script>') SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self) SheetsPage.closeSheets(self) SheetsPage.openSheets(self) time.sleep(5) self.assertNotIn(text1, self.driver.page_source) self.assertIsNot(True, self.driver.switch_to_active_element) # return test data: SheetsPage.editProductItemField(self, 'Test Item') SheetsPage.editSellerNameField(self, 'Test Description') SheetsPage.editDescription(self, 'Test Description') SheetsPage.editProductCode(self, 'Test Product Code') SheetsPage.clickSaveButton(self) HelperTestBase.clickYesButton(self)