我在 python 中有 2 个类,它们都扩展了 unittest.TestCase 类。因此我有2个测试用例。这些测试用例(类)是:
class Test_ID_94017(unittest.TestCase):
ex = Excel()
def setUp(self):
self.driver = Browser().createBrowserDriver()
self.driver.maximize_window()
self.driver.implicitly_wait(15)
self.ex.setUpASheetInExcel('Login')
def test_CCPD_Regression001_PER_Custom_Check(self):
ccp = CCPLogin(self.driver)
loginDetails = self.ex.getLoginDetailsForATestCaseFromExcel('Login', '94017')
ccp.login(loginDetails[0], loginDetails[1], loginDetails[2])
wait = WebDriverWait(self.driver, 20)
wait.until(lambda driver:self.driver.title.startswith('Harland Clarke'))
self.assertIn("Harland Clarke Checks Online Catalog", self.driver.title, "Failed on CHECKS ONLINE CATALOG PAGE")
Home().clickOrderButton(self.driver)
PersonalHurdle().clickProceedWithNoChangeLink(self.driver)
pc = ProductConfig()
pc.confirmAddress(self.driver, False)
pc.clickContinueButton(self.driver)
wait.until(lambda driver:self.driver.title.startswith('Customize Your Check'))
self.assertIn("Customize Your Check", self.driver.title)
try:
updateButtonHidden = self.driver.find_element_by_xpath(CustomizeYourCheckPage.UPDATE_BUTTON)
self.assertIn("hidden", updateButtonHidden.get_attribute('style'))
except NoSuchElementException:
assert 0, "Can't find hidden button"
self.driver.find_element_by_xpath(CustomizeYourCheckPage.SECOND_FONT).click()
updateButtonVisible = self.driver.find_element_by_xpath(CustomizeYourCheckPage.UPDATE_BUTTON)
self.assertIn("visible", updateButtonVisible.get_attribute('style'))
CustomizeYourCheck().clickAddToCartButton(self.driver)
time.sleep(5)
OrderExtraTodayPopup().clickNoThanksButton(self.driver)
wait.until(lambda driver:self.driver.title.startswith('Shopping Cart'))
assert "Shopping Cart" in self.driver.title
sc = ShoppingCart()
sc.selectItemQuantity(self.driver)
sc.clickProceedToCheckoutButton(self.driver)
wait.until(lambda driver:self.driver.title.startswith('Checkout'))
self.assertIn("Checkout", self.driver.title)
wait.until(lambda driver:self.driver.find_element_by_xpath(CheckoutStep1Page.SELECT_SHIPPING_METHOD_LINK).is_displayed())
self.driver.find_element_by_xpath(CheckoutStep1Page.SELECT_SHIPPING_METHOD_LINK).click()
time.sleep(10)
ShippingMethod().selectAShippingMethod(self.driver)
cs1 = CheckoutStep1()
cs1.enterEmailAddress(self.driver, "praveen@email.com")
cs1.clickProceedToOrderSummary(self.driver)
wait.until(lambda driver:self.driver.title.startswith('Order Summary'))
self.assertIn("Order Summary", self.driver.title)
OrderSummary().clickSubmitOrderButton(self.driver)
wait.until(lambda driver:self.driver.title.startswith('Order Confirmation'))
self.assertIn("Order Confirmation", self.driver.title)
OrderConfirmation().clickLogoutLink(self.driver)
wait.until(lambda driver:self.driver.find_element_by_css_selector(LogoutPopupWindow.YES_BUTTON).is_displayed())
self.driver.find_element_by_css_selector(LogoutPopupWindow.YES_BUTTON).click()
def tearDown(self):
self.driver.close()
和
class Test_ID_94018(unittest.TestCase):
ex = Excel()
def setUp(self):
self.driver = Browser().createBrowserDriver()
self.driver.maximize_window()
self.driver.implicitly_wait(15)
self.ex.setUpASheetInExcel('Login')
def test_CCPD_Regression002_PER_Std_Check(self):
ccp = CCPLogin(self.driver)
loginDetails = self.ex.getLoginDetailsForATestCaseFromExcel('Login', '94018')
ccp.login(loginDetails[0], loginDetails[1], loginDetails[2])
wait = WebDriverWait(self.driver, 15)
wait.until(lambda driver:self.driver.title.startswith('Harland Clarke'))
self.assertIn("Harland Clarke Checks Online Catalog", self.driver.title, "Failed on CHECKS ONLINE CATALOG PAGE")
PersonalHurdle(self.driver).clickProceedWithNoChangeLink()
pc = ProductConfig(self.driver)
pc.confirmAddress(False)
pc.clickContinueButton()
wait.until(lambda driver:self.driver.title.startswith('Customize Your Check'))
self.assertIn("Customize Your Check", CustomizeYourCheckPage)
CustomizeYourCheck(self.driver).clickAddToCartButton()
OrderExtraTodayPopup(self.driver).clickNoThanksButton()
wait.until(lambda driver:self.driver.title.startswith('Shopping Cart'))
assert "Shopping Cart" in self.driver.title
sc = ShoppingCart(self.driver)
sc.selectItemQuantity()
sc.clickProceedToCheckoutButton()
wait.until(lambda driver:self.driver.title.startswith('Checkout'))
self.assertIn("Checkout", self.driver.title)
wait.until(lambda driver:self.driver.find_element_by_xpath(CheckoutStep1Page.SELECT_SHIPPING_METHOD_LINK).is_displayed())
self.driver.find_element_by_xpath(CheckoutStep1Page.SELECT_SHIPPING_METHOD_LINK).click()
time.sleep(10)
ShippingMethod(self.driver).selectAShippingMethod()
cs1 = CheckoutStep1(self.driver)
cs1.enterEmailAddress("praveen@email.com")
cs1.clickProceedToOrderSummary()
wait.until(lambda driver:self.driver.title.startswith('Order Summary'))
self.assertIn("Order Summary", self.driver.title)
OrderSummary(self.driver).clickSubmitOrderButton()
wait.until(lambda driver:self.driver.title.startswith('Order Confirmation'))
self.assertIn("Order Confirmation", self.driver.title)
OrderConfirmation(self.driver).clickLogoutLink()
wait.until(lambda driver:self.driver.find_element_by_css_selector(LogoutPopupWindow.YES_BUTTON).is_displayed())
self.driver.find_element_by_css_selector(LogoutPopupWindow.YES_BUTTON).click()
def tearDown(self):
self.driver.close()
问题是当我尝试通过 PyUnit 在 Eclipse 中运行它时,只有第一个测试用例执行、通过并给我结果。第二个测试用例根本不执行。我记得,它之前执行了两个测试用例,但我不确定为什么现在不执行这两个测试用例。请指教。在这里需要帮助,因为我现在被阻止了!