Giter Club home page Giter Club logo

Comments (12)

jonleighton avatar jonleighton commented on August 19, 2024

This isn't possible at the moment but should be possible with the next version of PhantomJS.

from poltergeist.

sandro avatar sandro commented on August 19, 2024

Cool. I dig what you're doing with this project. Will happily give it another go in the future.

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

FWIW you could probably get around it by putting a Rack middleware around you app to set the header.

from poltergeist.

sandro avatar sandro commented on August 19, 2024

Unfortunately, headers aren't the only problem, it's just the problem I felt confident reporting an issue about. Currently, I can swap out capybara-webkit with selenium and all the tests pass. This is not the case with poltergeist, and I don't have the time to dig in further to find the actual problem. I've lazily resolved to give the project another shot sometime in the future.

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

If capybara-webkit solves your problems at the moment then I wouldn't suggest switching :)

Without more info it's hard to guess what might be the issue, but one key difference to c-w (and I think selenium) is that in poltergeist a click only works if the element is not obscured by another element (like in a real browser). I've added some code to master to detect whether a click will fail so if you're curious then give master a go.

from poltergeist.

elcuervo avatar elcuervo commented on August 19, 2024

I've looking at the code and i cannot set userAgent, not sure why.
Phantom now provides a: page.settings.userAgent = 'Something' which works, i've been looking at lib/capybara/poltergeist/client/web_page.coffee and for some reason

@native.settings.userAgent = "Something"

does not work.

Perhaps i'm missing something

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

@elcuervo sorry, I don't have any insight into your problem (though I haven't tried it myself)

FWIW PhantomJS now supports setting headers: https://code.google.com/p/phantomjs/issues/detail?id=452

But the code is in master - it's not supported in 1.5.0, so we'll need to wait for 1.6.0 to add this to Poltergeist.

from poltergeist.

elcuervo avatar elcuervo commented on August 19, 2024

Specifically i'm referring about doing something like this which works in 1.5.0: http://cl.ly/1q1j1Z1Z2S3Y22322V3a/Screen%20Shot%202012-05-04%20at%202.36.19%20PM.png

from poltergeist.

defeated avatar defeated commented on August 19, 2024

@elcuervo The .coffee files are compiled to .js in the client/compiled/ directory. I was able to override the user agent by adding:

this["native"].settings.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3";

in between lines 9 and 10 (https://github.com/jonleighton/poltergeist/blob/v0.6.0/lib/capybara/poltergeist/client/compiled/web_page.js#L9)

/cc @jonleighton

from poltergeist.

injcristianrojas avatar injcristianrojas commented on August 19, 2024

Curious hack. Worked like a charm though. Kudos, defeated.

from poltergeist.

carhartl avatar carhartl commented on August 19, 2024

In terms of setting the user agent see this: https://github.com/carhartl/poltergeist/tree/user_agent

from poltergeist.

jonleighton avatar jonleighton commented on August 19, 2024

Closing this as header support was added and there is a separate bug for the user agent issue.

from poltergeist.

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.