Comments (7)
@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.
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.
@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.
See this note: #73 (comment)
from ferrum.
@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.
I think you mean to tag @route -- I'm just a random onlooker who keeps close tabs on the project ;)
from ferrum.
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)
- Send Emulation commands to Page HOT 1
- Ferrum::BinaryNotFoundError when using docker for chrome HOT 1
- Can I allow Page.go_to take additional wait parameter?
- Cannot call `exit` from within `.on()` blocks HOT 2
- Exceptions within `.on()` blocks are mysteriously ignored HOT 1
- Browser start fails with JRuby on Windows
- Chrome error: "Unable to create temporary file" on Windows with JRuby HOT 1
- Errno::ECONNREFUSED on browser initialization HOT 3
- Headless new gives Ferrum::NoSuchPageError on screenshot HOT 2
- consider using === in network blacklist matching
- Doesn't work on ruby 3.2 HOT 1
- Saving via browser.mhtml and via cmd+S differs a lot on Youtube HOT 3
- Network.loadingFailed error preventing file from downloading HOT 13
- Conditionally Render Page header and footer template HOT 2
- browser.quit doesn't close session HOT 6
- Include type and stackTrace in logging for console API
- `wait_for_network_idle` failing due to pending requests on previous page HOT 1
- Remove `disable-gpu`default flag for Apple Silicon HOT 3
- authenticate current_user in ferrum browser
- Hang/Timeout in dialog HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ferrum.