import os

from selene import config
from selene.conditions import exact_text
from selene.tools import visit, make_screenshot, s

start_page = 'file://' + os.path.abspath(os.path.dirname(__file__)) + '/../resources/start_page.html'


def test_can_make_screenshot_with_default_name():
    visit(start_page)
    path = make_screenshot()
    assert "/Users/sepi/screenshots/screen_0.png" == path


def test_can_make_screenshot_with_custom_name():
    visit(start_page)
    path = make_screenshot(filename="custom")
    assert "/Users/sepi/screenshots/custom_1.png" == path


def test_can_save_screenshot_to_custom_folder():
    config.screenshot_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    visit(start_page)
    path = make_screenshot()
    assert "/Users/sepi/PycharmProjects/selene/tests/screen_2.png" == path
    assert os.path.isfile(path)


def test_can_make_screenshot_automatically():
    visit(start_page)
    s("#selene_link").should_have(exact_text("Selen site"))

@@ -4,16 +4,87 @@
 ort os%0A%0A
+import pytest%0Afrom selenium.common.exceptions import TimeoutException%0A%0A
 from sel
@@ -1000,24 +1000,70 @@
 start_page)%0A
+    with pytest.raises(TimeoutException):%0A    
     s(%22#sele
@@ -1110,8 +1110,91 @@
 site%22))%0A
+    assert os.path.exists(%22/Users/sepi/PycharmProjects/selene/tests/screen_3.png%22)%0A

test fixed