mercredi 29 janvier 2020

Have Ruby pull the last downloaded file of specific file type

I'm trying to run an automation test and the end download a document and puts the document file name into console. I'm having trouble helping it locate the most recent document. I'm using ruby and cucumber. Currently running on Firefox. Below is my specific step-def language that works to pull a file, but not exactly the most recent file:

When(/^I can see the file name of download pdf from the (.+) directory displayed on the console 
screen$/) { |path| 
 Dir.foreach(path) do |fname|
if fname.include?(".pdf")
  @file_name = fname
  break
end

end
puts @file_name }

Aucun commentaire:

Enregistrer un commentaire