Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Gus P
    @staycreativedesign
    k
    Gus P
    @staycreativedesign
    i replaced the csrf-token like this
    "X-CSRF-Token": document.querySelector("[name='csrf-token']")?.content,
    and it worked
    @twalpole ok its passing now :)
    @twalpole question you said something about transients does that make creating database stuff faster?
    Thomas Walpole
    @twalpole
    Not faster - but easier
    you can write your factories to accept the count of an association to create etc
    Gus P
    @staycreativedesign
    what makes testing faster since im creating all this dummy data?
    Thomas Walpole
    @twalpole
    run in transactions
    (if you're not)
    otherwise -- not much -- if you need to actually have the records accessible to the app then you need to create it
    Gus P
    @staycreativedesign
    k
    Boris Petrov
    @boris-petrov
    @twalpole - I have a div for which I have applied CSS display: contents !important;. Capybara doesn't seem to treat text in this div as visible - that is have_text doesn't find it (but says it has in non-visible text). Why is that?
    Thomas Walpole
    @twalpole
    @boris-petrov Couple of possibilities - 1. You're using the rack-test driver which only supports very basic inline CSS. 2. You're using selenium driver and there's a bug in the visibility atom. 3. Other CSS being applied is making the text non-visible.
    Boris Petrov
    @boris-petrov
    @twalpole thanks for the answer. I'm using Selenium on the latest Chrome. In the screenshot the text is absolutely visible. It could be a bug in the "visibility atom" I guess? Do you want a reproduction - would you look into one?
    Thomas Walpole
    @twalpole
    I would look into it -- although if it is a bug in the visibility atom that's a selenium thing
    Boris Petrov
    @boris-petrov
    I opened an issue - please check it when you can. teamcapybara/capybara#2497
    Thomas Walpole
    @twalpole
    @boris-petrov I've looked - definitely appears to be an issue but I'm not sure whether it's really in the selenium visibility calculation or in the browser behavior. The issue is likely because a display: contents element doesn't actually generate a box of any size and so text contents would be assumed to be overflowing that non-box which should mean they would be hidden (logically). What the real behavior should be will require a careful reading of the CSS spec around display: contents
    Boris Petrov
    @boris-petrov
    Do you need anything more from me? I can open an issue somewhere but perhaps it's better if you do it as you understand the problem better than me.
    Thomas Walpole
    @twalpole
    We need to work out whether it’s actually an issue in selenium or a browser bug that the text is shown
    Boris Petrov
    @boris-petrov
    Well, the text is shown on both Chrome and Firefox. I doubt both have the same bug.
    Thomas Walpole
    @twalpole
    @boris-petrov I don't know whether that's a good assumption - from https://developer.mozilla.org/en-US/docs/Web/CSS/display - Current implementations in most browsers will remove from the accessibility tree any element with a display value of contents (but descendants will remain). This will cause the element itself to no longer be announced by screen reading technology. This is incorrect behavior according to the CSS specification.`
    and from the CSS spec -https://www.w3.org/TR/css-display-3/#box-generation - Note: As only the box tree is affected, any semantics based on the document tree, such as selector-matching, event handling, and property inheritance, are not affected. As of writing, however, this is not implemented correctly in major browsers, so using this feature on the Web must be done with care as it can prevent accessibility tools from accessing the element’s semantics.
    I think this looks like a browser issue where the text really shouldn't be visible but is incorrectly shown by the browser
    Boris Petrov
    @boris-petrov
    I see. Maybe that makes sense. So we mark it as a browser bug and can close the issue?
    Thomas Walpole
    @twalpole
    @boris-petrov Probably. The other possibility is a spec bug, or possibly user error. Specifying overflow: hidden on an element whose box is removed from the render box tree doesn't make a lot of logical sense - and the behavior may not be specified because of that.
    Boris Petrov
    @boris-petrov
    OK, thanks for the help!
    Boris Petrov
    @boris-petrov
    Is it possible to work with the browser's context menu? Actually I just need to know if it has appeared or not. Doing page.driver.browser.action.context_click(find('video').native).perform does indeed open it but I can't seem to be able to work with it (via page.driver.browser.action.send_keys(:arrow_down).perform) or capture it in a screenshot. Any ideas?
    Mark McDonald
    @MarkyMarkMcDonald
    has anyone had success with using spring or zeus to run a spec that uses capybara (and doing it quickly)? One of our applications takes ~30 seconds to boot puma and so there's a long feedback loop when iterating on system specs. It seems like I could write some tooling that manages keeping the test server up in the background and then overwrite driver.needs_server? so capybara doesn't try to start one up? For context we use rspec / puma / selenium / firefox, but I don't think that would matter too much.
    Mark McDonald
    @MarkyMarkMcDonald
    oh I might be able to configure my own server proc that uses a preloader
    Gustavo Pares
    @gpares
      def simulate_failed_connection
        allow(Rails.cache).to receive(:stats).and_raise Redis::CannotConnectError
      end
    ```
    context 'cannot connect to redis' do
      before { simulate_failed_connection }
    
      it { logs_failed_connection }
      it { is_expected.to be false }
    end
    ```
    how can in the simulate_failed_connection just raise a Redis::CannotConnectError
    and remove a receive(stats)
    Arthur Nobrega
    @arthurnobrega
    I'm facing this kind of errors on my tests:
         Failure/Error: visit("/channels/cf_internal/jobs/#{job.id}/editor_preview")
    
         Capybara::Poltergeist::JavascriptError:
           One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
    
           TypeError: undefined is not a function (evaluating 'window.addEvent')
           TypeError: undefined is not a function (evaluating 'window.addEvent')
               at http://127.0.0.1:35487/channels/cf_internal/jobs/64/editor_preview:28 in global code
         # /usr/local/bundle/gems/poltergeist-1.17.0/lib/capybara/poltergeist/browser.rb:384:in `command'
         # /usr/local/bundle/gems/poltergeist-1.17.0/lib/capybara/poltergeist/browser.rb:39:in `visit'
         # /usr/local/bundle/gems/poltergeist-1.17.0/lib/capybara/poltergeist/driver.rb:99:in `visit'
         # /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/session.rb:227:in `visit'
         # /usr/local/bundle/gems/capybara-2.4.4/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
         # ./spec/features/cml/multiple_spec.rb:20:in `block (2 levels) in <top (required)>'
    Does anyone have a clue on how to fix it? It seems that the window object is not available
    Thomas Walpole
    @twalpole
    @gpares This is for discussions about Capybara - your question has nothing to do with Capybara
    @arthurnobrega Your problem is that window.addEvent isn't defined - likely due to using JS in your assets that isn't support by Poltergeist which then prevents other JS from being executed when all your assets are combined into one by the asset pipeline. The real solution is to stop using poltergeist - it was obsolete 3 years ago - time to move to a newer driver
    Arthur Nobrega
    @arthurnobrega
    Thanks, @twalpole. And sorry for the unrelated question. But I'm glad you could help me anyway. Have a great day!
    Gustavo Pares
    @gpares

    @twalpole would you able to help me on this one.

    Im thinking its my chrome browswer im using

    Thomas Walpole
    @twalpole
    @gpares you’re executing your script before query has been loaded in the page
    Gustavo Pares
    @gpares
    @twalpole how would I remedy situation?
    Gustavo Pares
    @gpares
    for capybara i havean iold setting like this
    Ive updated to gem webdrivers and the latest chromedriver as well
    driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
    Thomas Walpole
    @twalpole
    @gpares Look at when you're running the script and what the page status is -- if you want to be able to run that script at any time then just write plain JS which doesn't need JQuery
    or check whether $ exists before using it
    Gustavo Pares
    @gpares
    @twalpole is there a way where I can do a binding pry in cucumber and actually pause the test without cumumber going to a new thread?