简体   繁体   中英

Testing local website with Protractor

I am developing simple website (html, css) and I want to write few tests against it in Protractor.

Is it possible to check that kind of website with Protractor? I have html file on my computer only. Should I run this website locally on server? I don't think I can run test on file directly.

Yes, its possible to open a stand-alone local html file without hosting it on a local server.You have to add this browser.resetUrl = "file:///" in your onPrepare() function and then a browser.get("file:///C:/Users/demo/test.html") would work

There are some good examples @this question - Opening a file with protractor

A common way to do it is to approach it in multiple steps:

  • build your application
  • run a local web server from the build directory (I think this is the part you are asking about)
  • run tests against your app served by the local web server
  • stop the local web server

Usually, this multi-step process is handled by a task runner like grunt or gulp . We use grunt , grunt-contrib-connect to serve from a directory, grunt-protractor-runner to run protractor from grunt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM