How to set the browser width when running spec under phantomJS

836 views
Skip to first unread message

Kris Leech

unread,
Aug 22, 2014, 7:55:02 AM8/22/14
to jasmi...@googlegroups.com
The browser width `$(window).width()` defaults to `400px` when run using PhantomJS in CI. This is giving us different failures versus running on `localhost:8888` since that is wider.

I'd like to tell PhantomJS the browser width before the specs start running, something like `page.driver.width = 1000`. I've done plenty of Googling but couldn't find an answer.

Many thanks, Kris.

Gregg Van Hove

unread,
Aug 22, 2014, 3:42:14 PM8/22/14
to jasmi...@googlegroups.com
I think what you're looking for is `page.viewportSize`. If you're using the jasmine ruby gem, we just pushed a commit to master that should allow you to configure your phantom runner, including with this option. See the docs here: http://jasmine.github.io/edge/ruby_gem.html#section-Configuring_the_default_phantomjs_runner

-Gregg


--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Kris Leech

unread,
Sep 15, 2014, 2:43:52 PM9/15/14
to jasmi...@googlegroups.com
Many thanks for the reply. Using the latest from master as soon as I add `phantom_config_script: 'spec/javascripts/support/phantom_config.js'` to jasmine.yml running `rake jasmine:ci` it hangs after `jasmine server started.`.

The Javascript file definitely exists at that path relative to the root (the file is empty, so no errors inside the file).

Any ideas? 

Gregg Van Hove

unread,
Sep 15, 2014, 3:55:31 PM9/15/14
to jasmi...@googlegroups.com
Looks like the phantom runner probably isn't handling errors very well here. It's expecting to be able to call a `configure` function that is exported from the file, when that doesn't exist, it throws but doesn't properly tell the jasmine gem to stop the run.

-Gregg

Kris Leech

unread,
Sep 16, 2014, 4:33:38 AM9/16/14
to jasmi...@googlegroups.com
Indeed it works perfectly when I add the `exports.configure`, which I only removed because it was hanging, the mystery of computers...

Thanks!

Gregg Van Hove

unread,
Sep 16, 2014, 12:02:07 PM9/16/14
to jasmi...@googlegroups.com
I made a github issue for this here: https://github.com/pivotal/jasmine-gem/issues/229. I think in have a fix that will stop the run and show the error when it fails. I should get a chance to push it to master later today. 

- Gregg
Reply all
Reply to author
Forward
0 new messages