Ruby on Rails Wednesday, May 27, 2015

Currently I'm trying use a statement IF (If a button appears in the page, then run the IF), see the method Login in the system:

If the button doesn't appear in the page, I would like to run the next method Remove and add new expense

require "selenium-webdriver"  require "rspec"  require "rspec/expectations"    describe "#Add simple expense and after add a receipt", :suitee => true do    before(:all) do    @driver = Selenium::WebDriver.for :chrome    @base_url = "http://sitetest.com"    @driver.manage.window.maximize  end    it "Login in the system" do    @driver.get(@base_url)    @driver.find_element(:id, "user_email").send_keys "rafael@gmail.com"    @driver.find_element(:id, "user_password").send_keys "123456"    @driver.find_element(:name, "commit").click      if(@driver.find_element(:css, ".btn.btn-lg.btn-success.btn-block").displayed?)          @driver.find_element(:css, ".btn.btn-lg.btn-success.btn-block").click          @driver.find_element(:css, ".introjs-button.introjs-skipbutton").click          @driver.find_element(:css, ".i.i-pencil").click      end  end    it "Remove and add new expense" do    begin       while(@driver.find_element(:css, ".i.i-pencil.icon").displayed?)       button = @driver.find_element(:id, "expense-bulk-select")       @driver.action.click(button).perform        delete = @driver.find_element(:id, "delete-multi-btn")       @driver.action.click(delete).perform       waitDisplayModal = Selenium::WebDriver::Wait.new(:timeout => 10)       waitDisplayModal.until {@driver.find_element(:class => "bootstrap-dialog-footer-buttons")}       @driver.find_element(:xpath, "//div[3]/div/div/button[2]").click        sleep 3    end   rescue Selenium::WebDriver::Error::NoSuchElementError      @driver.find_element(:id, "current_expense_merchant").send_keys "Taxi to work"      @driver.find_element(:id, "current_expense_amount").send_keys "50"     @driver.find_element(:id, "button-add-expense").click     waitDisplayIconTrash = Selenium::WebDriver::Wait.new(:timeout => 20)     waitDisplayIconTrash.until {@driver.find_element(:css => ".i.i-pencil.icon")}   end  end     after(:all) do    @driver.quit      end  end


My problem: When I run this script, appears this in my console:

Failure/Error: if(@driver.find_element(:css, ".btn.btn-lg.btn-success.btn-block").displayed?)   Selenium::WebDriver::Error::NoSuchElementError:     no such element       (Session info: chrome=42.0.2311.135)       (Driver info: chromedriver=2.9.248304,platform=Linux 3.13.0-24-generic x86_64)


That is, the IF is not working as I would like. How can I fix it?

CHeers

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/13389273-1da5-49a1-beda-2a850ec54e8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi,

I have downloaded the source of spring gem and made some changes. Now I want to use this modified gem in my application. So how to do that ?

I tried 1 thing :-
Firstly I added `gem spring, :path=>"path to my local spring folder"`
Then I ran `bundle install` successfully and it installed spring(1.3.6) also.Now when I ran ` bundle exec spring binstub --all`  it gave ;-

You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).

This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.

Here's the backtrace:

/home/puneet/.rvm/gems/ruby-2.2.2/bin/spring:23:in `load'
/home/puneet/.rvm/gems/ruby-2.2.2/bin/spring:23:in `<main>'
/home/puneet/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
/home/puneet/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'

please help me out with this.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0a262062-f740-4785-8c09-95ff8fb66220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello,

If I am understanding correctly, you need some mechanism to correlate several models together, you are hoping to use the created_at and modified_at timestamps provided by active record, to match the models using a timestamp.

I see the created_at and modified_at timestamp's as database level information - I try not to rely on these for my business logic as they represent when the database record was created and modified, this is a separate concern to the actual business transaction. 

Anything in my business domain that I want to record a time against I try model that explicitly. In this case I would consider introducing a transaction_completed_at column (or a UUID). Or take it a step further and model a transaction separately and add a foreign key in each of the other models.

The way I see it, transaction_completed_at will tell me when the transaction completed and created_at and modified_at will tell me when it was persisted  and modified in the database.

Thanks,
Henry 

On 27 May 2015 at 00:28, Ruby Railhead <rubyrailhead@gmail.com> wrote:
Hello, Frederick:

Thanks for your response, that was very helpful both in validating my approach, and suggesting other ways to accomplish this.

I'm still surprised this issue hasn't come up for others ... does anyone else have input on how this should/shouldn't be performed, or how they solved this issue? 

(For those just tuning in, I need all the updated_on/created_on timestamps, in a series of AR object created/updated within a transaction, to match exactly)

Thanks again,
  Ruby



On Thursday, May 21, 2015 at 5:20:59 AM UTC-4, Frederick Cheung wrote:


On Thursday, May 21, 2015 at 6:58:35 AM UTC+1, Ruby Railhead wrote:

Idea 3: Subclass ActiveRecord::Base (to say ActiveRecordLocal) and mix in the modules mentioned above into this class. 
Thoughts: This makes is clearer that when you're using ActiveRecordLocal, you're not getting the stock ActiveRecord::Base behavior. Otherwise this solution is identical to Idea 2.


Of the ideas you outline, I would either do this or:

- use SomeModel.record_timestamps = false to stop active record setting timestamps
- use before_save / before_create callbacks  (or override save) to set your own timestamps
- continue overriding transaction in order to get your start of transaction timestamp. 

The reason for this slightly different strategy is that it means you're only overriding public methods, so their api will remain stable (or at least go through the usual deprecation cycle) across versions of active record.

Fred 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4674c558-dbba-4b48-9f27-ed9f1ac00406%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mobile: +61 4 0136 1909

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPeHLo%3DUTjZe736vxJrjKmm%3DHrQmtcVQYYpB1jaFvVcUQ%2Bi-WQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.