导入测试(Python、Unittest、WebDriver、PyCharm)时,将打开第二个页面,地址为“数据:”

问题描述 投票:0回答:0

导入测试时,会打开第二个页面,地址为“数据:” 因此,导入测试失败。我没有发现错误。 请告诉我它在哪里。这种做法有多好?

导入测试.py:

import unittest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import import_test_set


class ImportTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.url = "https://www.google.com/"
        cls.s = Service("../chromedriver/chromedriver")
        cls.driver = webdriver.Chrome(service=cls.s)

        cls.driver.maximize_window()

    def test_00_01_open_site(self):
        self.driver.get(self.url)

    def test_00_02_imported_tests(self):
        suite = unittest.TestSuite()
        suite.addTest(unittest.findTestCases(import_test_set))
        runner = unittest.TextTestRunner()
        runner.run(suite)

import_test_set.py:

import unittest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By


class ImportTestSet(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.s = Service("../chromedriver/chromedriver")
        cls.driver = webdriver.Chrome(service=cls.s)
        cls.i_wait = 5

    def test_00_02_01_enter(self):
        self.driver.implicitly_wait(self.i_wait)
        a_enter = self.driver.find_element(By.LINK_TEXT, 'Sign in')
        a_enter.click()
        page_title = self.driver.title
        self.assertEqual(page_title, 'Google Account:')

假设只会打开一个页面,在该页面上执行导入的测试

python unit-testing selenium-webdriver pycharm
© www.soinside.com 2019 - 2024. All rights reserved.