Python 为什么我不能自动执行这段代码?

Python 为什么我不能自动执行这段代码?,python,selenium,Python,Selenium,我无法访问此代码,它显示在0.000秒内运行了0个测试 from selenium import webdriver import unittest from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options class execute(unittest.Test

我无法访问此代码,它显示在0.000秒内运行了0个测试

from selenium import webdriver
import unittest
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options


class execute(unittest.TestCase):
        def setUp(self):
            chrome_options: Options = webdriver.ChromeOptions()
            chrome_options.add_argument("--Person1")
            chrome_options.add_argument("--start-maximized")
            driver = webdriver.Chrome(chrome_options=chrome_options)
            driver.get('http://localhost/dashboard/user/login')


        def login(self):
         self.driver.find_element_by_id('uemail').send_keys('xyz@gmail.com')
         self.driver.find_element_by_id('upwd').send_keys('123')
         self.driver.find_element_by_id('upwd').send_keys(Keys.RETURN)

        def test_method(self):
            self.setUp()
            self.login()

        def TearDown(self):
            self.driver.close()

        if __name__ == "__main__":
            unittest.main()
这个缩进不正确。。因此,
unittest.main()
将不会执行

chrome\u选项:选项=webdriver.ChromeOptions()

这不是有效的Python。你可能是说:


chrome\u options=webdriver.ChromeOptions()

您的最后两行是否真的缩进了类中?您需要将它们从类中拉出,因此,
if…
从行的开头开始。。您的身份证已关闭。复制/粘贴错误或实际错误。
if __name__ == "__main__":
    unittest.main()