Mechanize Ignore Javascript when Required by Page
I understand a few people have asked about JS support in Mechanize. My question might be a little bit different, and/or posed differently. I am looking to ignore the Javascript check and log in to a page that requires Javascript. The web site itself does not really need JS, but the developers felt they needed to require it for the best appearance.
开发者_StackOverflowWith that said, has anyone been able to circumvent the check for JS? I could use Watir, Watij, Selenium, or a surplus of other utilities but they open an actual browser which was not that desirable -- but if this is the only way I guess I'll go that route.
I'm running Mac OS X, Ruby 1.8.7, Mechanize/Hpricot (latest as of this post). Thanks.
Generally speaking, the simplest option is to work out what the server expects the user-agent to send to claim that it supports JS (either by monitoring the HTTP requests (perhaps with Charles Proxy) sent by a browser with JS enabled or by reverse engineering the JS) and then just having your script send that information.
You could try Webrat. Webrat doesn't understand JavaScript as far as I know.
- Webrat
精彩评论