setup_frame('loginframe') within_frame('loginframe') do fill_in 'TPL_username', :with => username fill_in 'TPL_password', :with => password click_button '登录' end rescue => e puts e end
defsetup_frame(name) jquerify page.execute_script %Q{ jQuery('iframe').attr('name', '#{name}'); } end
defjquerify page.execute_script %Q{ var jq = document.createElement('script'); jq.src = "http://code.jquery.com/jquery-latest.min.js"; document.getElementsByTagName('head')[0].appendChild(jq); } # wait to load jquery sleep 2 end
defbrick visit('/') 10000.downto(1).each do find('#J_Vol_Brick_Btn').click sleep 1 end rescue sleep 5 retry end