Reputation: 115
Is it possible to run tests one by one in one tab ? When i run my code both test runs at the same time
from selenium import webdriver
import unittest
from selenium.webdriver.common.by import By
`from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import WebDriverWait
from SlackHome import SlackHome
from mailPage import MailPage
from SlackApp import SlackMain
class SlackTest(unittest.TestCase):`
`@classmethod
def setUpClass(self):
self.driver = webdriver.Chrome('/Users/piotrkapczynski/PycharmProjects/teraz to bedzie dzialac/chromedriver')
self.driver.get("https://slack.com/signin")
def test_logToSlack(self):
driver = self.driver
time.sleep(3)
SlackH = SlackHome(driver)
SlackH.sendDomain()
SlackH.submitDomain()
time.sleep(3)
SlackH.loginInput()
time.sleep(3)
SlackH.passwordInput()
SlackH.signIn()
time.sleep(2)
def test_inviteUsers(self):
driver = self.driver
SlackA = SlackMain(driver)
time.sleep(3)
SlackA.inviteUser()
SlackA.addNewUser('aaa')`
Upvotes: 1
Views: 794
Reputation: 11414
No, tests are run independently so you can't keep state between different tests. From the docs:
A new TestCase instance is created as a unique test fixture used to execute each individual test method. Thus
setUp()
,tearDown()
, and__init__()
will be called once per test.
What you could do is to define test_logToSlack
as a normal method (so a method without the test
prefix) instead and call it from test_inviteUsers
.
Or if you want the code in test_logToSlack
to be called for in every test in your test case, you can put it's code in a setUp
method.
Upvotes: 1