class NewTC3_EditUser(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.login = NewLogin()
        self.browser = self.login.login()

    def test_editUser(self):
        # pwd = "Apple123"
        newUsername = "******"
        print(">>> running test3: edit user")
        self.browser.get(self.user_url)
        time.sleep(5)
        print("username: "******"//a[contains(text(),'" +
                                           newUsername + "')]").click()
        edit = self.browser.find_element_by_id("btnSave")
        edit.click()
        print("Editing the username ")
        self.browser.find_element_by_class_name("addbutton").click()
        print("Saved the username")

    @classmethod
    def tearDownClass(self):
        u = Utilities()
        print("Quiting the browser")
        u.closeBrowser(self.browser)
class NewTC2_AddUser(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.login = NewLogin()
        self.browser = self.login.login()

    def test_addUser(self):
        self.user_url = "https://opensource-demo.orangehrmlive.com/index.php/admin/viewSystemUsers"
        pwd = "Apple123"
        newUsername = "******"
        print(">>> running test2: add user")
        self.browser.get(self.user_url)
        self.browser.find_element_by_name("btnAdd").click()
        self.browser.find_element_by_id("systemUser_employeeName_empName").send_keys("linda anderson" + Keys.TAB)
        self.browser.find_element_by_name("systemUser[userName]").send_keys(newUsername + Keys.TAB)
        checkValidationError = self.browser.find_element(By.CLASS_NAME, "validation-error").is_displayed()
        assert (checkValidationError == False)
        self.browser.find_element_by_id("systemUser_password").send_keys(pwd)
        self.browser.find_element_by_name("systemUser[confirmPassword]").send_keys(pwd)
        self.browser.find_element_by_id("btnSave").click()
        time.sleep(2)
        print("Username is saved ")


    @classmethod
    def tearDownClass(self):
        u = Utilities()
        print("Quiting the browser")
        u.closeBrowser(self.browser)
Пример #3
0
class NewTC1_SearchUser(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        self.login = NewLogin()
        self.browser = self.login.login()

    def test_searchUser(self):
        self.user_url = "https://opensource-demo.orangehrmlive.com/index.php/admin/viewSystemUsers"
        print(">>> running test1: search user")
        self.browser.get(self.user_url)
        print("User page is opened ")

        userRole = Select(self.browser.find_element_by_name("searchSystemUser[userType]"))
        userRole.select_by_visible_text("All")
        self.browser.find_element_by_id("searchBtn").click()
        time.sleep(2)
        usernames = self.browser.find_elements_by_xpath("//table[@id='resultTable']//tbody//a")
        counter = 0
        for n in usernames:
            counter += 1
            print(counter, n.text)
        print("search results count:", counter)

    @classmethod
    def tearDownClass(self):
        u = Utilities()
        print("Quiting the browser")
        u.closeBrowser(self.browser)
class NewTC4_DeleteUser(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.login = NewLogin()
        self.browser = self.login.login()

    def test_deleteUser(self):
        newUsername = "******"
        print(">>> running test4: delete user")
        self.browser.get(self.user_url)
        self.browser.find_element_by_xpath("//a[text()='" + newUsername +
                                           "']//../..//input").click()
        self.browser.find_element_by_id("btnDelete").click()
        time.sleep(1)
        self.browser.find_element_by_id("dialogDeleteBtn").click()

    @classmethod
    def tearDownClass(self):
        u = Utilities()
        print("Quiting the browser")
        u.closeBrowser(self.browser)