Coder Social home page Coder Social logo

capybara-angular's People

Contributors

alex-hall avatar atermenji avatar bobziuchkovski avatar brentwheeldon avatar cayblood avatar cyborgmaster avatar esaborit4code avatar joshnuss avatar kibenimatik avatar mathieujobin avatar mwean avatar psyho avatar rodrigodiez avatar slike9 avatar wrozka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capybara-angular's Issues

Debug the timeout while waiting for angular

Is there an easy way to track the list of outstanding requests in order to debug this? After upgrading capybara and capybara-angular, our test suddenly stopped working due to this error. It works fine before the upgrade.

Manual bootstrapping angular not supported

As per Angular 2 documentation:

Pure Angular 1 applications can be bootstrapped in two ways: By using an ng-app directive 
somewhere on the HTML page, or by calling angular.bootstrap from JavaScript. In Angular 2, only 
the second method is possible - there is no ng-app in Angular 2. This is also the case for hybrid 
applications. Therefore, it is a good preliminary step to switch Angular 1 applications to use the 
JavaScript bootstrap method even before switching them to hybrid mode.

So in order to get this gem working with Angular 2 or even hybrid ng-upgrade apps, ng-app can no longer be required.

The protractor documentation solved this problem in a similar way to how the gem has solved it, so only minor updates are required.

I have already forked the gem and made the change here: #33

capybara-angular does not wait for route changes

I am testing a login page, and after a successful login, I should be redirected to the dashboard page.
I am using the ng-routes module, not the angular-ui-router. My test for asserting this route change always fails.
my assertion looks like this:

expect(current_url).to eq("#{@app_host}/#/dashboard")

I see that the way capybara-angular checks to see if angular is ready is just by counting outstanding XHR requests.I think waiting for route changes should be a part of what this library covers.

Warnings from Ruby 2.4

We switched to Ruby 2.4 and now we're getting many warnings. They mostly fall into two categories:
/usr/local/bundle/gems/capybara-angular-0.2.6/lib/capybara/angular/dsl.rb:13: warning: instance variable @ignoring_angular not initialized
and
/usr/local/bundle/gems/capybara-angular-0.2.6/lib/capybara/angular.rb:10: warning: instance variable @default_max_wait_time not initialized
They appear to be harmless but they happen often enough that it makes it hard to find legit log messages.

This project is not functional?

I executed any tests with gem capybara-angular, but unsuccessfully! For example, why not find with <fill_in 'user.login', :with => 'teste'> ??? I tried find "ng-model" or "ng-click" directives using fill_in and find, but unsuccessfully. I inspected source code, but I did not find the functions. The capybara-angular is the project a skeleton?

How do I use this with PhantomJS/Poltergeist?

Im using poltergeist as my JS driver for Capybara. I installed this gem but didnt notice anything different. Im still getting race errors where Capybara moves on before all Angular AJAX requests are completed.

window.angularReady is undefined sometimes

I've noticed that whenever my cucumber tests throw 'timeout waiting for angular', the reason seems to be that window.angularReady returns 'undefined', thus causing the loop to continue until a timeout is thrown.

To reproduce this, I simply executed a 'puts ready?' right before the new timeout is raised in the timeout! method.

I'm not sure why window.angularReady would be undefined. It's clearly being defaulted to 'false' in the setup_ready method. Perhaps the window object is being changed in some way that loses the 'angularReady' attribute.

timeout while waiting for angular

Hello!
I'm trying to create a basic feature spec using capybara / rspec / angular but i'm not able to make my code working.

require 'rails_helper'

feature "Jobs Management", :type => :feature, current: true do
  include Capybara::Angular::DSL

  scenario 'SA creates a new Job' do
    Capybara.current_driver = :webkit

    visit '/#/users/sign_in'
    fill_in 'field-email', with: '[email protected]'
    fill_in 'field-password', with: 'TestPass'
    click_button 'Sign in'
  end

end

The following spec throws timeout while waiting for angular exception. Am i doing something wrong? Thanks in advance for any clues

My env:
ruby 2
rails 4.1.0
rspec 3

how does this capybara-angular actually works

I would to know more about how this lib works. Does it waits for all the http traffic to finish.

As soon as in include include Capybara::Angular::DSL I see scripts failing. May be if I understand what it does then I should be able to get my scripts stable.

Does nothing when using PhantomJS/Poltergeist

Adding the gem and adding include Capybara::Angular::DSL does nothing at all. With or without it a random number of tests is failing depending on how fast AngularJS is building the screen.

Strange thing: using 0.0.4 - tried "ng-app" instead of "data-ng-app". Working. Looked at the code "[ng-app], [data-ng-app]" - so why I can use it with ng-app and why it completely ignores data-ng-app? LOL???

Not waiting for $http

I'm using ui.router and angularjs-rails-resource.

The page I'm visiting has a directive that performs a query to the local API to get some models that populate a select for a form:

CarBrand.query().then(function(carBrands) {
  vm.carBrands = carBrands; // this never gets executed, the model is empty
});

I've opened the page with save_and_open_page to check the rendering state of the app, and the route is resolved (even without using the waiter mentioned in this other issue) and the form is rendered, but the select options are not populated.

I've run out of clues. I checked if there are pending requests as suggested here but the answer is no, there are no pending requests.

However, when I quit, in the last second the requests appear en in the network tab of firefox, as if something was holding them.

Test:

require "rails_helper"

describe "CarListing creation", type: :feature do
  let!(:car_version) { FactoryGirl.create :car_version }

  it "creates a CarListing", js: true do
    visit "/#/avisos/nuevo"

    wait_until_angular_ready
    wait_for_route_changes

    save_and_open_page

    select_by_ng_model "cL_EC.carListing.car.brand", car_version.brand.name
    select_by_ng_model "cL_EC.carListing.car.model", car_version.model.name
    select_by_ng_model "cL_EC.carListing.car.versionId", car_version.id
    fill_in_by_ng_model "cL_EC.carListing.car.year", 1996
  end

  def fill_in_by_ng_model(ng_model, value)
    find_by_ng_model(ng_model).set value
  end

  def select_by_ng_model(ng_model, value)
    find_by_ng_model(ng_model).
    find(:css, "option[value='#{value}']").
    select_option
  end

  def find_by_ng_model(ng_model)
    find(:css, "[ng-model='#{ng_model}']")
  end
end

I tried https://github.com/kikonen/capybara-ng with the same results. AFAIK, this library angularjs-rails-resource is just a wrapper around $http calls.

Any help is aprettiated!

providing angular-mock ?

In the last version of Angular, the $interval service is introduced and should replace calls to setInterval in the application. This have the main effect of being able to mock this service during tests (with angular-mock) and make the application stop changing continuously.

What do you think of providing angular-mock for that purpose ?

Looking for a new maintainer?

Hello,

I recently found out we still use this gem.

We have a monkey patch for ruby 3.0, and Rails 7
but its working fine for us... so no reason to replace it.

would you accept a patch and make a new release?

otherwise, if you can give me access to push releases to rubygems, I would fork and push directly to rubygems, I would hate having to rename.

I maintain many legacy gems such as this one. please have a look at my profile.

https://rubygems.org/profiles/mathieu

Thank you

ignoring-angular doesn't work?

In a feature I have:

ignoring_angular do
   visit "/"
end

If I have this in my capybara env.rb

include Capybara::Angular::DSL

Then the wait for angular always happens. I think the @ignoring_angular variable isn't been set correctly.

However if I have:

World(Capybara::Angular::DSL)

Then it works as advertised.

Request for Assistance: Understanding the Gap

Sorry, folks, for submitting this as an issue โ€” I couldn't find an email address to which I would send this inquiry.

I'm trying to understand the functionality gap in Capybara that this gem addresses. From what I can tell, reading through Capybara::Node::Base#synchronize, as long as an expectation is not met, it will retry up to some maximum timeout. This means that if an expectation has not yet been met, regardless of the delay, Capybara "waits." (really, it retries)...

So, how does the situation improve by specifically querying Angular for its internal state? I suspect I'm missing something important yet subtle.

Thanks!

Serializer not working with title attribute when running capybara-angular

Hi, I have a strange problem.

Reported it here: rails-api/active_model_serializers#1518

The problem is: I can't test json stuff with capybara-angular that has as "title" attribute :D

As soon as I enable a completely stupid attribute called "title" in my model (ActiveRecord) I run into "Timeout::Error: timeout while waiting for angular" issues. Removing or renaming the attribute and everything is working fine. Debugged into the stuff:

[155, 164] in /Users/atrapp/.rvm/gems/ruby-2.2.1@aquadb2/gems/active_model_serializers-0.9.3/lib/active_model/serializer.rb
   158:     def attributes
   159:       filter(self.class._attributes.dup).each_with_object({}) do |name, hash|
=> 160:         hash[name] = send(name)
   161:       end
   162:     end

is working like it should for all attributes that are NOT named title and just returns the value of that attribute:

[83, 92] in /Users/atrapp/.rvm/gems/ruby-2.2.1@aquadb2/gems/active_model_serializers-0.9.3/lib/active_model/serializer.rb
   87:           define_method striped_attr do
=> 88:             object.read_attribute_for_serialization attr
   89:           end unless method_defined?(attr)

If the attribute is called "title" I am hijacked and land here (after 1 step):

[3, 12] in /Users/atrapp/.rvm/gems/ruby-2.2.1@aquadb2/gems/capybara-angular-0.2.3/lib/capybara/angular/dsl.rb
    3:     module DSL
    4:       include Capybara::DSL
    6:       Capybara::Session::DSL_METHODS.each do |method|
    7:         define_method(method) do |*args, &block|
=>  8:           page.send(method, *args, &block)
    9:         end
   10:       end

"self" is always my ContactPersonSerializer, :title is just an :attribute as all others too. Really confused now... I have absolutely no idea why the serializer is calling Capybara or how Capybara may hijack my serializer...

I really would need some help here because I don't have any clue what's going on.

gems:

capybara (2.6.2)
capybara-angular (0.2.3)
capybara-screenshot (1.0.3)
active_model_serializers (0.9.3)

Thank you very much in advance for every hint!

suggested docs for Cucumber

If someone else needs to use this with cucumber (and I wish I didn't have to use cucumber myself!), this took me a bit to figure out, but seems to work. In your cucumber support/env.rb:

require 'capybara/angular'
World(Capybara::Angular::DSL)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.