我编写了一个脚本来创建一个文本文件,并保存我需要保存的所有内容。问题出现在我循环并更改目录以将文件上传到另一个目录后,但文本文件留在旧目录中。
如何更改目录但仍写入文本文件?这是我的代码:
kolekcija.each do |fails|
@b.send_keys :tab
@b.span(:class => "btnText", :text => "Save", :index => 1).when_present.click
@b.frame(:id, "uploadManagerFrame").table(:id, "ctrlGetUploadedFiles_gvUploadedFiles").wait_until_present
sleep 30
# I need to edit it so it opens the TXT file in its existing location
output = File.open("#{Time.now.strftime("%Y.%m.%d")} DemoUser.txt", "a")
output.puts ""
output.puts "Korpusā ielādētais fails: #{File.basename(@fails)} augšuplādēts sekmīgi..."
output.close
progress.increment
end