def cleanup(cls, url):
     SplinterWrapper.open(url)
     if cls.browser.is_element_present_by_id("action-toggle"):
         fill_form(cls.browser, {"action-toggle": True})
         fill_form_and_submit(cls.browser, {"action": "delete_selected"},
                              "index", True, True)
         cls.browser.find_by_value("Yes, I'm sure").first.click()
    def test_login_redirects_to_admin_dashboard_on_success(self):
        SplinterWrapper.open("/accounts/logout")
        SplinterWrapper.open("/accounts/login")
        fill_form(self.browser, {"username": "******", "password":"******"}, True, True)
        self.browser.find_by_value("Login").first.click()

        self.assertEqual(self.browser.is_text_present('Add New Poll'), True)
    def create_poll(cls, browser, name, type, question, group):
        SplinterWrapper.open("/createpoll/")
        form_data = {"id_type": type, "id_name": name, "id_groups": group}
        browser.fill("question_en", question)
        fill_form(browser, form_data)
        browser.find_by_css(".buttons a").last.click()

        return browser.url.split('/')[-2]
    def respond_to_the_started_poll(cls, sender, message):
        SplinterWrapper.open('/router/console/')
        rows_responses = rows_of_table_by_class(cls.browser, "messages module")
        number_of_responses = len(rows_responses)

        form_data = {"text": message, "sender": sender}
        fill_form(cls.browser, form_data, True)
        cls.browser.find_by_css("input[type=submit]").first.click()
        return number_of_responses
    def test_login_redirects_to_admin_dashboard_on_success(self):
        SplinterWrapper.open("/accounts/logout")
        SplinterWrapper.open("/accounts/login")
        fill_form(self.browser, {
            "username": "******",
            "password": "******"
        }, True, True)
        self.browser.find_by_value("Login").first.click()

        self.assertEqual(self.browser.is_text_present('Add New Poll'), True)
    def create_poll(cls, browser, name, type, question, group):
        SplinterWrapper.open("/createpoll/")
        form_data = {
            "id_type": type,
            "id_name": name,
            "id_groups": group
        }
        browser.fill("question_en", question)
        fill_form(browser, form_data)
        browser.find_by_css(".buttons a").last.click()

        return browser.url.split('/')[-2]
    def respond_to_the_started_poll(cls, sender, message):
        SplinterWrapper.open('/router/console/')
        rows_responses = rows_of_table_by_class(cls.browser, "messages module")
        number_of_responses = len(rows_responses)

        form_data = {
            "text": message,
            "sender": sender
        }
        fill_form(cls.browser, form_data, True)
        cls.browser.find_by_css("input[type=submit]").first.click()
        return number_of_responses
 def cleanup(cls, url):
     SplinterWrapper.open(url)
     if cls.browser.is_element_present_by_id("action-toggle"):
         fill_form(cls.browser, {"action-toggle": True})
         fill_form_and_submit(cls.browser, {"action": "delete_selected"}, "index", True, True)
         cls.browser.find_by_value("Yes, I'm sure").first.click()
 def cleanup(self, url):
     self.open(url)
     if self.browser.is_element_present_by_id("action-toggle"):
         fill_form(self.browser, {"action-toggle": True})
         fill_form_and_submit(self.browser, {"action": "delete_selected"}, "index", True, True)
         self.browser.find_by_value("Yes, I'm sure").first.click()