硒+鼻子 - N-1测试无头

时间:2017-08-21 21:44:47

标签: selenium selenium-chromedriver

有些陌生感。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

driver = None
class TestThreshold:

    def __init__(self):
        self.driver = webdriver.Chrome()
    def waitForId(self,type,id):
        try:
            element_present = EC.presence_of_element_located((type,id))
            WebDriverWait(self.driver, 10).until(element_present)
        except TimeoutException:
            print "Timed out waiting for page to load"
    def setUp(self):
        # code that uses driver.login to login

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

    def test_login(self):
        # a test with assertion

    def test_feature(self):
        # a test with assertion


    def test_admin(self):
        # another test with assertion

当我运行nosetests Chrome浏览器弹出时。它会停留在空白页面上,然后最终运行test_logintest_feature然后退出。

所有3个测试都通过(在Ran 3 tests的CLI中获得OK,但只能在视觉上显示1。三个中的两个以无头型模式运行,而页面空白了一点。

如何在没有无头的情况下从头到尾运行所有测试? (如果我想,我怎么能让他们无头?)

我还注意到,如果我继续添加测试,它总会运行N-1测试无头(一个将在视觉上运行)

1 个答案:

答案 0 :(得分:0)

所以这让我开怀大笑。原因是因为有多个Chrome窗口堆叠在一起。它不是按顺序并行运行。