-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce driver registration #133
Changes from 1 commit
265bd41
f75b1ab
3f4fe61
3d8592d
8a32eee
5a947ff
35c8854
10f6672
968d1fc
2b36a00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Could delete screenshots taken from different driver in same suite
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
abstract class LuckyFlow::Driver | ||
@retry_limit : Time = 2.seconds.from_now | ||
|
||
getter session : Selenium::Session do | ||
prepare_screenshot_directory | ||
start_session | ||
end | ||
getter session : Selenium::Session { start_session } | ||
|
||
abstract def start_session : Selenium::Session | ||
abstract def stop | ||
|
@@ -18,6 +15,11 @@ abstract class LuckyFlow::Driver | |
stop | ||
end | ||
|
||
def screenshot(path : String) | ||
FileUtils.mkdir_p(File.dirname(path)) | ||
session.screenshot(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this also use the instance variable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the only places I used the instance variable was places where if it was never started, there's nothing to stop/reset |
||
end | ||
|
||
protected def retry_start_session(e) | ||
if Time.utc <= @retry_limit | ||
sleep(0.1) | ||
|
@@ -26,13 +28,4 @@ abstract class LuckyFlow::Driver | |
raise e | ||
end | ||
end | ||
|
||
private def prepare_screenshot_directory | ||
FileUtils.rm_rf(screenshot_directory) | ||
FileUtils.mkdir_p(screenshot_directory) | ||
end | ||
|
||
private def screenshot_directory | ||
LuckyFlow.settings.screenshot_directory | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to the driver instead of the session so that the driver could make the screenshot directory if it's missing