Exemple #1
0
    def test_logout(self):

        try:
            driver = self.driver
            home=HomePage(driver)
            home.click_profile()
            time.sleep(8)
            home.click_logout()
            #driver.find_element_by_id("profilePopover").click()
            #driver.find_element_by_xpath("//ul[@class='dropdown-menu profile-tab']/li[4]/strong/a[text()='Logoff']").click()
            time.sleep(5)
            x=driver.title
            assert x=="LHH NGen"

        except AssertionError as error1:
            print("unwanted error")
            print (error1)
            allure.attach(self.driver.get_screenshot_as_png(),name="screen_1", attachment_type=allure.attachment_type.JPG)
            raise
    def test_logout(self):  #prevoiusly  def test_logout(self,test_setup):

        try:
            driver = self.driver
            homepage = HomePage(driver)
            homepage.click_welcome()
            homepage.click_logout()

            assert self.driver.title == "OrangeHRM"
            #assert title == "OrangeHRM"
        except AssertionError as error:

            print("assertion error has occured")
            print(error)
            currenttime = moment.now().strftime("%d-%m-%Y_%H-%M-%S")
            testName = utils.whoami()
            screenshotName = testName + "_" + currenttime
            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            driver.get_screenshot_as_file(
                "C:/Users/Sudheera Adusupalli/PycharmProjects/AutomationProject1/screenshots/"
                + screenshotName + ".png")
            raise
        except:
            currenttime = moment.now().strftime("%d-%m-%Y_%H-%M-%S")
            testName = utils.whoami()
            screenshotName = testName + "_" + currenttime
            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            driver.get_screenshot_as_file(
                "C:/Users/Sudheera Adusupalli/PycharmProjects/AutomationProject1/screenshots/"
                + screenshotName + ".png")
            print("There was an exception")
            raise
        else:
            print("no exceptions as occured:")
        finally:
            print("i am in finally block:")
        '''
    def test_logout(self):
        try:

            driver = self.driver
            homepage = HomePage(driver)
            homepage.click_welcome()
            homepage.click_logout()
            x = driver.title
            assert x == "OrangeHRM"

        except AssertionError as error:
            print("Assertion error occurred")
            print(error)
            currTime = moment.now().strftime("%H-%M-%S_%d-%m-%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + currTime
            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            driver.get_screenshot_as_file(
                "C:/Users/Rameesha/PycharmProjects/AutomationFrameworkPractice_1/screenshots/"
                + screenshotName + ".png")
            raise

        except:
            print("Exception")
            currTime = moment.now().strftime("%H-%M-%S_%d-%m-%Y")
            testName = utils.whoami()
            screenshotName = testName + "_" + currTime
            allure.attach(self.driver.get_screenshot_as_png(),
                          name=screenshotName,
                          attachment_type=allure.attachment_type.PNG)
            raise
        else:
            print("No exception")
        finally:
            print("Finally block")
Exemple #4
0
from selenium import webdriver
from testdata.data import *
from pages.loginpage import LoginPage
from pages.homepage import HomePage

driver = webdriver.Chrome(
    executable_path=
    "C:/Users/SRIHARI/PycharmProjects/Framework_POM/drivers/chromedriver.exe")
driver.get(URL)
driver.implicitly_wait(30)
driver.maximize_window()

lp = LoginPage(driver)
lp.enter_un()
lp.enter_pwd()
lp.click_login()

hp = HomePage(driver)
hp.click_logout()
 def test_logout(self):
     driver = self.driver
     logout = HomePage(driver)
     logout.click_welcomLink()
     logout.click_logout()