我是一名初学者自动化测试人员,试图一次运行两种情况,其中一种情况是从另一个python文件导入的。问题是,pycharm仅运行一个测试用例。我的代码可能存在逻辑问题或完全错误。需要您的建议。谢谢。
Login.py
class Myloginclass(unittest.TestCase):
def test_TC_1_login_page(self):
self.driver = webdriver.Firefox()
self.driver.get("URL")
self.driver.find_element_by_xpath("//*[@id='employee_id']").send_keys("Email")
self.driver.find_element_by_xpath("//*[@id='password']").send_keys("password")
self.driver.find_element_by_xpath("//*[@id='emp_login']").click()
if __name__ == '__main__':
unittest.main(failfast=True, exit=False)
Lunch.py
import unittest
from selenium import webdriver
import Login
unittest.main(module=Login)
class Lunch(unittest.TestCase):
def test_tc_3_lunch(self):
lunch_order_option = "/html/body/aside/section/ul/li[13]/a/span[1]"
lunch_menu_option = "/html/body/aside/section/ul/li[13]/ul/li[1]/a"
first_order_click = "/html/body/main/div/section/div[2]/div/div/div/table/tbody/tr[1]/td[7]/button"
place_order_button = "/html/body/main/div/section/div[1]/div[1]/div[2]/div[1]/input"
confirm_button_popup = "/html/body/main/div/section/div[5]/div/div/div[2]/div[2]/div[1]/form/input[4]"
history_option = "/html/body/aside/section/ul/li[13]/ul/li[2]/a"
self.driver = webdriver.Firefox()
self.driver.find_element_by_xpath(lunch_order_option).click()
self.driver.find_element_by_xpath(lunch_order_option).click()
self.driver.find_element_by_xpath(lunch_menu_option).click()
self.driver.find_element_by_xpath(first_order_click).click()
self.driver.find_element_by_xpath(place_order_button).click()
self.driver.find_element_by_xpath(confirm_button_popup).click()
self.driver.find_element_by_xpath(history_option).click()
amount = self.driver.find_element_by_xpath('/html/body/main/div/section/div/div[4]/div[4]/div[2]').text
print(amount)
if __name__ == '__main__':
unittest.main(failfast=True, exit=False)
现在Pycharm仅成功运行登录文件。 请帮忙。预先感谢