Code Monkey home page Code Monkey logo

Comments (7)

PandaWhisperer avatar PandaWhisperer commented on May 12, 2024 3

@ttilberg as far as I can tell I AM using the master branch.

I did some digging and I found the method implementation here

      def css(selector, within: nil)
        code = <<~JS
          let selector = arguments[0];
          let within = arguments[1] || document;
          let results = within.querySelectorAll(selector);
          arguments[2](results);
        JS


        evaluate_async(code, @page.timeout, selector, within)
      end

I copied the JS code definition and ran the same browser.evaluate_async call in my local console. Still getting the same error.

HOWEVER, while futzing around with this I also found the solution: document.querySelector() returns a NodeList, not an Array (as the XPath version does). So, I changed the JS code to turn the NodeList into an Array, like so:

let selector = arguments[0];
let within = arguments[1] || document;
let results = [].slice.apply(within.querySelectorAll(selector));
arguments[2](results);

Running this code using browser.evaluate_async worked, and returned the expected result.

from ferrum.

route avatar route commented on May 12, 2024 1

Sorry guys I had a branch when you tagged me but then life came in and walked me away lol. I like your soultion @PandaWhisperer and I'm gonna intro one more thing, let me rebase and continue working in my branch.

from ferrum.

ttilberg avatar ttilberg commented on May 12, 2024

Related: #73 #13

@PandaWhisperer can you try with master branch? It was mentioned in #73 that a fix was added, but it looks like a new release hasn't been cut.

Edit: not a fix, just perhaps a better error.

from ferrum.

ttilberg avatar ttilberg commented on May 12, 2024

See this note: #73 (comment)

from ferrum.

PandaWhisperer avatar PandaWhisperer commented on May 12, 2024

@ttilberg does this make sense?

I've been trying to come up with a test case for this scenario, but so far I have failed. I see the Browser#css method has tests and works for the cases you have for it. So far I haven't been able to figure out what's different between your test cases and "in the wild" pages.

from ferrum.

ttilberg avatar ttilberg commented on May 12, 2024

I think you mean to tag @route -- I'm just a random onlooker who keeps close tabs on the project ;)

from ferrum.

route avatar route commented on May 12, 2024

I merged one more thing regarding cyclic structure but @PandaWhisperer I think this rubycdp/cuprite@62e2a27 should have fixed your issue any chance you were using old branches? Please upgrade ferrum and let me know if it's still an issue for you. Thanks!
PS: Tried your scenario on master, everything works now.

Sorry I forgot we have different selectors in ferrum. Fixing right now

from ferrum.

Related Issues (20)

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.