質問

Currently I'm using a combination of specflow, selenium, fluent automation and xunit to test my browser application on a deployed instance of the website in chrome. This works well on a developer machine but frequently fails on the build server agents for no apparent reason other than the build server agents are slow.

I've been all over the phantom.js documentation I'm struggling to understand if I can use phantom.js to test my application fully.

My application has a lot of javascript logic, I use requirejs to load all my modules and I'm wondering if I can use phantom's headless browser functionality to test all the functionality of it. Will it download all the javascript files and then allow me to do actions on the dom like launching modals that have forms in them? Lots of the UI is built with knockout templating.

I've done a few searches but nothing definitive has come up. Does anyone have any advice on this? I'm not so bothered about cross browser testing at this point, we've got manual QA for that. This would just be for a happy-path early warning system of functionality failing through ui-automation of all the user stories.


At the end of all this I made a couple of changes which were really useful

  • Accessing the selenium driver and checking for jQuery.active
  • Creating a new expectOne/assertOne which throws if the css selector returns more than one item for a selector
役に立ちましたか?

解決

PhantomJs is a complete browser implementation that just doesn't render to the screen (it does have a buffer that can be captured via screenshot though). If manual testing covers the preferred browsers and you just need to know hard failures, give it a shot!

FluentAutomation.SeleniumWebDriver supports PhantomJs out of the box in current versions. Just choose PhantomJs as your 'browser' and it'll work. The FluentAutomation.PhantomJs provider is deprecated and will go away.

FluentAutomation.SeleniumWebDriver.Bootstrap(FluentAutomation.SeleniumWebDriver.Browser.PhantomJs);

他のヒント

Yes.

You might find CasperJS more useful for testing. The built-in tester module is quite easy to use. Casper also opens up using SlimerJS (for Gecko/Firefox testing) with no additional code needed.

In either Phantom or Casper You can use page.evaluate() to run any client-side JavaScript, so that should be no problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top