这是我的代码,但它显示没有找到测试,并打印空套房
import unittest
import time
from selenium import webdriver
class LoginTest(unittest.TestCase):
driver = webdriver.Chrome(executable_path="C:\\Users\\win\\Desktop\\chromedriver.exe")
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome(executable_path="C:\\Users\\win\\Desktop\\chromedriver.exe")
cls.driver.implicitly_wait(10)
def Test(self):
self.driver.get("https://opensource-demo.orangehrmlive.com/")
self.driver.find_element_by_id("txtPassword").send_keys("admin123")
self.driver.find_element_by_id("txtUsername").send_keys("Admin")
self.driver.find_element_by_id("btnLogin").click()
time.sleep(2)
@classmethod
def tearDownClass(cls):
cls.driver.close()
cls.driver.quit()
print("Test Complete")
if __name__ == '__main__':
unittest.main()我编写了这段代码,但是在运行我的Test时,它显示如下:
Testing started at 2:47 PM ...
C:\PycharmProject\OrangeHRM\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_unittest_runner.py" --target LoginTest.LoginTest
Launching unittests with arguments python -m unittest LoginTest.LoginTest in C:\PycharmProject\OrangeHRM\ScriptsDemo\Tests
Ran 0 tests in 0.000s
OK
Process finished with exit code 0
No Tests were found
Empty suite发布于 2020-03-02 10:43:17
在单位库中,有一个命名约定,所有测试都以' test‘开头,这将通知测试运行程序哪些方法代表测试。
您必须将“测试”方法更改为“测试”。
https://stackoverflow.com/questions/60485764
复制相似问题