即使成功执行代码后,pytest说空套件,并且不打印打印语句

时间:2019-05-30 13:26:03

标签: python python-3.x automation

我正在尝试使用import从pytest中的其他模块运行一种方法。它可以正常运行,但在报告中显示为空套件。它不打印打印语句。

roboForm.py-

import unittest
from selenium import webdriver
from selenium.webdriver.support.select import Select
class Roboform(unittest.TestCase):
    def setUp(self):
        # create a new Chrome session
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("https://www.roboform.com/filling-tests")
    def click_Custom_Form(self):
        # get the xpath of the link and page
        title = self.driver.title
        assert title== "RoboForm Form Filling Tests"
        print("We are on the right page")
        #click on custom form link
        self.custom_form = self.driver.find_element_by_xpath("//*[contains(text(),'Custom')]").click()
    def close_browser(self):
        self.driver.quit()

我正在pytest中运行以下代码-test_classB.py

import self as self
from roboForm import Roboform
class Test():
    Roboform.setUp(self)
    print ("Browser and page launched from RoboForm")
    self.driver.find_element_by_xpath("//*[contains(text(),'Custom')]").click()
    print ("Test Passed")
    Roboform.close_browser(self)

出现以下错误:

=========================没有测试在11.53秒内运行================= =======

以退出代码0结束的过程

空套房

空套房

1 个答案:

答案 0 :(得分:-1)

与@Corey Goldberg达成协议。

尝试

def test_click_Custom_Form(self):

代替

def click_Custom_Form(self):