First I wanted to set this up on my machine and on a mac mini that I use at work so I had to figure out a way to detect the os since the file path is different on a mac vs pc.
def is_mac?
RUBY_PLATFORM.downcase.include?("darwin")
end
def is_windows?
RUBY_PLATFORM.downcase.include?("mingw32")
end
Code:
file_path="C:\\Users\\Leo\\Dropbox\\QA scripts\\Screenshots\\" if is_windows? file_path="/Users/administrator/Dropbox/QA\ scripts/Screenshots/" if is_mac?
After that I wanted to make sure that the files are saved will consisst the name of the
test-case + date and time so I will know later which one is which. Here is how the magic happens.
@selenium.capture_entire_page_screenshot("#{file_path}NameOfTestCase#{Time.now.strftime("%Y-%m-%d_%H%M")}.png", '');
No comments:
Post a Comment