Class09 Answer:

Enhance ~fx411/fx411/spec/features/truefx_spec.rb

For me this was an easy lab.

I put my username and password into the script.

It is obvious where they should go:


# spec/features/truefx_spec.rb
# Demo:
# bin/rspec spec/features/truefx_spec.rb

# I should have executable:
# chromedriver
# in my path.
# I put it here: ~/fx411/bin/chromedriver

require 'rails_helper'

describe 'This should start Chrome', :js => true do
  it 'should visit some links' do
    Capybara.app_host = 'https://www.truefx.com'
    ahost             = Capybara.app_host
    visit '/'
    sleep 1
    find(:xpath, "//a[@href='?page=logina']").click
    sleep 1
    within("#login-form") do
      fill_in 'USERNAME', with: 'bob1999'
      sleep 1
      fill_in 'PASSWORD', with: 'year2k3k'
      sleep 1
      click_on 'Login'
      sleep 1
    end
    months_s_a = ['JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER']
    months_i_a = ['01','02','03','04','05','06','07','08','09','10','11','12']
    m_i        = -1 # I should use this to count months in the loop below.
    years_a    = [2010,2011,2012,2013,2014,2015,2016]
    pairs_a    = ['AUDUSD','EURUSD','GBPUSD','USDCAD','USDJPY']
    for month_s in months_s_a do
      m_i += 1
      for yr_i in years_a do
        for pair in pairs_a do
          p "#{ahost}/dev/data/#{yr_i}/#{month_s}-#{yr_i}/#{pair}-#{yr_i}-#{months_i_a[m_i]}.zip"
          visit     "/dev/data/#{yr_i}/#{month_s}-#{yr_i}/#{pair}-#{yr_i}-#{months_i_a[m_i]}.zip"
          sleep 40
        end
      end
    end
    
    # logout
    find(:xpath, "//a[@href='?page=logout']").click
    sleep 1
  end
end

Class09 Lab


ml4.us About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen