How can I create log files on loop using mechanize with ruby -
i trying make more 1 log file on localhost
one file sign_in.rb
require 'mechanize' @agent = mechanize.new page = @agent.get('http://localhost:3000/users/sign_in') form =page.forms.first form["user[username]"] ='admin' form["user[password]"]= '123456' @agent.submit(form,form.buttons.first) pp page the second profile_page.rb
require 'mechanize' require_relative 'sign_in' page = @agent.get('http://localhost:3000/users/admin') form =page.forms.first form.radiobuttons_with(:name => 'read_permission_level')[1].check @agent.submit(form,form.buttons.first) pp page how can combine these 2 files , run them on loop in order create more 1 log file
i don't know mechanize, there reason can't combine 2 bits of code , put them while loop? don't know how need mechanize.new. make more 1 log file, open 2 different files , write them.
require 'mechanize' require_relative 'sign_in' log1 = file.open("first.log", "w") log2 = file.open("second.log", "w") @agent = mechanize.new while true # @agent = mechanize.new # not sure if needed page = @agent.get('http://localhost:3000/users/sign_in') form = page.forms.first form["user[username]"] ='admin' form["user[password]"]= '123456' @agent.submit(form,form.buttons.first) pp.pp page, log1 # @agent = mechanize.new # not sure if needed page = @agent.get('http://localhost:3000/users/admin') form = page.forms.first form.radiobuttons_with(:name => 'read_permission_level')[1].check @agent.submit(form,form.buttons.first) pp.pp page, log2 end
Comments
Post a Comment