AngularJs end

Given a site with an existing extensive set of test cases written in Java using Selenium for a site, and this site is being re-written in AngularJs, how does one go about integrating the Selenium tests into the new app?

I have looked into Protractor, the new recommended end-to-end test runner that uses Selenium, however, this appears to suggest writing test in Javascript. This article goes into a little more detail about how to get this set up working, but again, the tests are written in Javascript.

As much as I would like to write the tests in Javascript, I would like to avoid a rewrite, so a means to get the existing ones integrated would be nice. Is there a configuration in Protractor that would enable this to happen?


I am afraid there is no good solution for you here. There are numerous obstacles in your way.

  • Protractor is written in JavaScript and is a wrapper around Selenium's WebDriverJS implementation. Given that WebDriverJS uses a very different API than the Java WebDriver (due to node's asynchronous nature), even if it is technically possible to get a node library to wrap a Java library, it would not work in this case.
  • Protractor and Selenium do not support the same API, so even if there were a Java based Protractor, you would find yourself doing a bit of retooling anyway.
  • If you are leveraging Angular then while the overall behavior of your page may be the same the underlying DOM structure, etc will not be. Either this or you are significantly failing to leverage Angular. Therefore unless you have a really good Page Object abstraction layer in place, you are going to have to rewrite your tests anyway. If you do have a good Page Object layer in place, you will need to rewrite that layer in any event.
  • In my opinion your best best are as follows:

    If your specs themselves are written in a higher level spec language like Cucumber, then those , in theory at least, can be ported to javascript using cucumber-js and you can simply re-implement the underlying definitions (no small task) on top of protractor.

    You could get really ambitious and port protractor to Java if it seems like that is less effort than rewriting your tests in javascript. You would then be at liberty to minimize issue #2 above but I still think #3 would lead you to conclude that porting your tests to javascript has the lower LOE.

    链接地址: http://www.djcxy.com/p/50752.html

    上一篇: Hudson和CruiseControl for Java项目有什么区别?

    下一篇: AngularJs结束