コード例 #1
0
        def test_times_out_even_if_time_is_frozen(self, session):
            session.visit("/with_js")
            now = time.time()

            with patch.object(time, "time", return_value=now):
                with pytest.raises(ElementNotFound):
                    session.find("//isnotthere")
コード例 #2
0
        def test_raises_an_error_suggesting_that_capybara_is_stuck_in_time(
                self, session):
            session.visit("/with_js")
            now = time.time()

            with patch.object(time, "time", return_value=now):
                with pytest.raises(FrozenInTime):
                    session.find("//isnotthere")
コード例 #3
0
    def test_generates_sensible_filename(self, session):
        with patch.object(session.driver,
                          "save_screenshot") as save_screenshot:
            session.save_screenshot()

            regex = re.compile(os.path.abspath("capybara-\d+\.png"))

            assert len(save_screenshot.call_args_list) == 1
            assert regex.search(save_screenshot.call_args[0][0])
コード例 #4
0
    def test_saves_file_in_custom_save_path(self, session, alternative_path):
        with patch.object(session.driver,
                          "save_screenshot") as save_screenshot:
            capybara.save_path = alternative_path

            session.save_screenshot()

            regex = re.compile(
                os.path.normpath(
                    os.path.join(alternative_path, "capybara-\d+\.png")))

            assert len(save_screenshot.call_args_list) == 1
            assert regex.search(save_screenshot.call_args[0][0])
コード例 #5
0
    def test_allows_one_to_specify_another_path(self, session,
                                                alternative_path):
        with patch.object(session.driver,
                          "save_screenshot") as save_screenshot:
            capybara.save_path = alternative_path

            custom_path = "screenshots/1.png"
            session.save_screenshot(custom_path)

            regex = re.compile(re.escape(custom_path) + "$")

            assert len(save_screenshot.call_args_list) == 1
            assert regex.search(save_screenshot.call_args[0][0])
コード例 #6
0
    def test_saves_file_relative_to_custom_save_path(self, session,
                                                     alternative_path):
        with patch.object(session.driver,
                          "save_screenshot") as save_screenshot:
            capybara.save_path = alternative_path

            custom_path = "screenshots/1.png"
            session.save_screenshot(custom_path)

            regex = re.compile(
                os.path.normpath(
                    os.path.join(alternative_path, re.escape(custom_path))))

            assert len(save_screenshot.call_args_list) == 1
            assert regex.search(save_screenshot.call_args[0][0])