为什么我不能执行second.py

时间:2018-10-01 17:17:21

标签: python selenium

first.py

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import HtmlTestRunner


class Environment(unittest.TestCase):

    def setUp(self):

        self.driver = webdriver.Chrome(executable_path="D:\\auto\\chromedriver.exe")

    # login test case
    def test_login(self):
        driver = self.driver
        driver.maximize_window()
        driver.get("http://localhost/dashboard/user/login")
        self.driver.find_element_by_id('uemail').send_keys('xyz@gmail.com')
        self.driver.find_element_by_id('upwd').send_keys('1234567890')
        self.driver.find_element_by_id('upwd').send_keys(Keys.RETURN)

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


if __name__ == "__main__":
        unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='D:\\auto\\reports'))

second.py

import unittest
import HtmlTestRunner
import first


class Notification(environment.test_login):

    def test_going_notification_page(self):

        going_noti_page = self.driver.find_element_by_class_name('color7')
        print(self.driver.execute_script("arguments[0].click();", going_noti_page))

    if __name__ == "__main__":
        unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='D:\\auto\\reports'))

1 个答案:

答案 0 :(得分:1)

修复ifsecond.py语句的缩进。现在,它在类定义中,这是错误的。