class SmokeTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def classSetup(self, oneTimeSetUp):
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)
        #self.np = NavigationPage(self.driver)
        self.re = RegisterAgentPage(self.driver)

    @pytest.mark.run(order=1)
    @data(*getCSVData(
        "/Users/enriquealejandro.d/PycharmProjects/WKSelenium/testdata.csv"))
    @unpack
    def test_valid(self, user, password, domesticCSV, countyCSV, companyCSV,
                   ccvCSV):
        self.lp.login(user, password)
        self.re.registerAgent(domestic=domesticCSV,
                              county=countyCSV,
                              companyname=companyCSV,
                              cvv=ccvCSV)
        result2 = self.re.verifyOrderConfirmation()
        result3 = self.re.captureOrderNumber()
        self.re.logoutMyCT()
        self.ts.mark(result2, "Order Created" + str(result3))
        self.ts.markFinal("test_sanity_registeredAgent", result2,
                          "Order was placed correctly")
def OneTimeSetUP(request, browser):
    print(" Running class level SetUp")
    # if browser == 'chrome':
    #     #########
    #     # reCAPTCHA ISSUE WORKOROUND in Chrome webbrowser
    #     #  https://www.loom.com/share/f2a51d18919d4b70a6d837524ff0e018
    #     ################
    #     # first open chrome://version/
    #     # than copy profilepath from there
    #     # here in this computer path is
    #     # /Users/parulagarwal/Library/Application Support/Google/Chrome/Default
    #     # paste it in opt.argument() and follow the following steps
    #
    #     opt = webdriver.ChromeOptions()
    #     opt.add_argument("user-data-dir=/Users/parulagarwal/Library/Application Support/Google/Chrome/Default")
    #     baseUrl = "https://learn.letskodeit.com/"
    #     driver = webdriver.Chrome(options=opt)
    #     driver.get(baseUrl)
    #     driver.maximize_window()
    #     driver.implicitly_wait(10)
    #     print("Running test on Chrome")
    # else:
    #     baseUrl = "https://learn.letskodeit.com/"
    #     driver = webdriver.Firefox()
    #     driver.get(baseUrl)
    #     driver.maximize_window()
    #     driver.implicitly_wait(10)
    #     print("Running test on Firefox")

    wd = WebDriverFactory(browser)
    driver = wd.getWebDriverInstance()

    # create login_page instance here and login to application

    lp = LoginPage(driver)
    lp.login('*****@*****.**', 'abcabc')

    # means if the class attribute we re getting request from is not None
    if request.cls is not None:
        # then this value will be avilable to complete class instance
        request.cls.driver = driver

    # this will return value to the place where this OneTimeSetUp fixture is used
    yield driver
    driver.quit()
    print(" Running class level Teardown")
class IncorporateTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def classSetup(self, oneTimeSetUp):
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)
        #self.np = NavigationPage(self.driver)
        self.ic = IncorCompanyPage(self.driver)

    @pytest.mark.run(order=1)
    def test_registeredagent(self):
        self.lp.login("*****@*****.**", "Today123")
        #result1 = self.lp.verifyTitle()
        #self.ts.mark(result1, "Title Verified")
        self.ic.incorpService("Connecticut", "Test", "Company_Test", "243")
        result2 = self.ic.verifyOrderConfirmation()
        result3 = self.ic.captureOrderNumber()
        self.ts.mark(result2, "Order Created" + str(result3))
        self.ts.markFinal("test_sanity_registeredAgent", result2,
                          "Order was placed correctly Incorporate Services")
class LoginTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def classSetup(self, oneTimeSetUp):
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)

    @pytest.mark.run(order=1)
    def test_validLogin(self):
        self.lp.login("*****@*****.**", "Today123")
        result1 = self.lp.verifyTitle()
        self.ts.mark(result1, "Title Verified")
        result2 = self.lp.verifyLoginSuccessful()
        self.ts.markFinal("test_validLogin", result2, "Login was successful")

    @pytest.mark.run(order=2)
    def test_invalidLogin(self):
        self.lp.login("*****@*****.**", "abcabcabc")
        result = self.lp.verifyLoginFailed()
        self.ts.markFinal("test_invalidLogin", result,
                          "Login was unsuccessful")
class LoginTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def classSetUp(self, OneTimeSetUP):
        self.lp = LoginPage(self.driver)
        self.tc = TestStatus(self.driver)

    @pytest.mark.run(order=2)
    def test_ValidLogin(self):

        self.driver.implicitly_wait(5)

        self.lp.login('*****@*****.**', 'abcabc')

        result1 = self.lp.verifyLoginTitle()
        # assert result1 == True
        self.tc.mark(result1, " Title is not correct")

        result2 = self.lp.verifyLoginSuccessful()
        # assert result2 == True
        self.tc.markFinal("test_ValidLogin", result2,
                          " Element not present here")

    @pytest.mark.run(order=1)
    def test_invalidLogin(self):

        self.driver.implicitly_wait(10)

        # INVALID DATA OPTIONS
        self.lp.logout()
        sleep(3)

        self.lp.login('test.email@com', 'qwe')

        #self.lp.login()
        #self.lp.login(username='******')
        #self.lp.login(userpassword='******')

        result = self.lp.verifyLiginFailed()
        assert result == True