AnglularJS: Can Protractor run on Windows? - angularjs

The angular doc recommends Protractor for e2etesting.
http://docs.angularjs.org/guide/dev_guide.e2e-testing
I didn't find any doc about running it on Windows.
Can Protractor run on Windows?
**
Update:
I have some experience on Selenium using C# code to call functions in some selenium dlls to control IE brower.
But what are the relationship between Protractor, Selenium and NodeJS?
Is Protractor an tool(exe) or a lib(dll) or a JS lib(like Jasmine)?

Yes, you can run it on windows.
I hope this guide will help you:
http://www.ng-newsletter.com/posts/practical-protractor.html
You should Start Selenium local server and use this basic configuration for run protractor (Depending routes):
chromeDriver: './node_modules/protractor/selenium/chromedriver',
specs: ['test/e2e/**/*_spec.js'],
chromeOnly: true,
chromeDriver: './node_modules/protractor/selenium/chromedriver',
seleniumAddress: 'http://0.0.0.0:4444/wd/hub'

Yes at least it should. It runs on node and node runs on windows. However sometimes projects have windows issues, the most common cause IMO is hardcoding of / etc.. If the library uses node path and similar os independent apis then all is fine.
I have ran protractor on windows without any issues. But not extensively.

Prerequisites & Installation:
Prerequisites
Node.js (Latest Version)
Download NodeJS
Install NodeJs
To test Node.Js installation properly open command prompt and execute the command.
Java Development Kit(JDK)
Download the JDK
Install JDK from
Installation
Install Protractor Globally
Open the command prompt and type following command to install protractor globally.
npm install -g protractor
This will install two command line tools, protractor and webdriver-manager. Try running below command to check protractor version.
protractor –version
The webdriver-manager is a helper tool to easily get an instance of a Selenium Server running. Use it to download the necessary binaries with:
webdriver-manager update
Now start up a server with:
webdriver-manager start

Related

Invalid or corrupt jar file when trying to start selenium server from intelliJ

I am trying to start my selenium server from intelliJ and it is saying the file is corrupt.
I use intelliJ to run my protractor tests, and when I starts the selenium server from the intelliJ terminal before I run them. For whatever reason it is saying my jar file for selenium-server-standalone is coming back as corrupt. Is there a way to fix this and, if not, is there a way to delete and then reinstall selenium server?
C:\Users\pheonix.jones\IdeaProjects\attensity-q-protractor>webdriver-manager
start [11:39:09] I/start - java
-Dwebdriver.chrome.driver=C:\Users\pheonix.jones\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.46.exe
-Dwebdriver.gecko.driver=C:\Users\pheonix.jones\AppData\Roaming\npm\node_modules\pro
tractor\node_modules\webdriver-manager\selenium\geckodriver-v0.24.0.exe
-jar C:\Users\pheonix.jones\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-4.0.0-alpha-1.zip.jar
-port 4444 [11:39:09] I/start - seleniumProcess.pid: 2748 Error: Invalid or corrupt jarfile
C:\Users\pheonix.jones\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-4.0.0-alpha-1.zip.jar
[11:39:09] I/start - Selenium Standalone has exited with code 1
As you can see, it is just exiting after it comes back as corrupt. I haven't had issues with this before. I did try to update the webdriver.
I found a workaround, which may or may not be acceptable. You can force webdriver-manager to use an older version of the selenium-standalone package. This avoids whatever the problem is with 4.0.0-alpha-1.
$ webdriver-manager clean
$ webdriver-manager update --standalone --versions.standalone=3.8.0
$ webdriver-manager start --versions.standalone=3.8.0
…
[14:19:55] I/start - seleniumProcess.pid: 63863
14:19:55.379 INFO - Selenium build info: version: '3.8.0', revision: '924c4067df'
14:19:55.380 INFO - Launching a standalone Selenium Server
2019-04-24 14:19:55.483:INFO::main: Logging initialized #390ms to org.seleniumhq.jetty9.util.log.StdErrLog
There is an open defect in the webdriver-manager project for this issue: https://github.com/angular/webdriver-manager/issues/370
As a temporary workaround you can use the directConnect attribute in your protractor config.
There is issue with 4.0.0-alpha-1 , after deleting files you can install some older versions that will work. If you will just update wevdriver manager by using webdriver-manager update then it will not work for you but you need to use something like " webdriver-manager update --standalone --versions.standalone="some older version"
Since you are using Protractor, you can try a webdriver-manager update
You should be starting the server like this - webdriver-manager start
I believe Protractor's webdriver-manager already contains the selenium standalone server.
Or you can just add this line in your conf file, and you will no longer need to manually start anything before running a Protractor spec file directConnect: true

Start Appium Server on bat file with version 1.6.4

With the previous version of Appium, I could start an appium server through command line in batch like this.
START node.exe node_modules\appium\bin\appium.js --port 4723
But now since the new release 1.0.0 (or 1.6.4) depends on how you calling it, There no node.exe anymore or appium.js either.
Can someone tell me where can I find these file ? or the "new" way of doing it ?
Thanks a lot !
With Appium 1.6.4, there are 2 ways of installing/using it -
We can do it the old fashioned way with Node. Installation happens via node with command - npm install -g appium. Then you can run it the same way you mentioned in your post.
If we install it via Appium Desktop (v1.0.0), then we don't need Node and the server can be started using the Appium Desktop UI.
I have also used appium -a 127.0.0.1 -p 4723 in command prompt and it works fine. And if you want to look at Java code to start appium, you can check this out as well - Start Appium server with Java
You can use main.js in place of appium.js to start the appium, it is the change we need to incorporate from Appium 1.6.4

Start Selenium server automatically for e2e testing

I followed this SO post
to set up my Gruntfile. If I manually downloaded Selenium standalone and specified its location in the file, my test runs successfully. Since I would like to automate this process, I tried the following configuration:
protractor_webdriver: {
start: {
options: {
path: 'node_modules/grunt-protractor-runner/node_modules/protractor/bin/',
command: 'webdriver-manager start'
}
}
};
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('test', ['protractor_webdriver:start','protractor:run'])
Is there a way to avoid downloading manually? I tried the above but when I ran it, I got the warning:
Running "protractor_webdriver:start" (protractor_webdriver) task
Verifying property protractor_webdriver.start exists in config...OK
File: [no files]
Options: path="node_modules/grunt-protractor-runner/node_modules/protractor/bin/", command="webdriver-manager start", keepAlive=false
Starting Selenium server
>> Selenium Standalone is not present.
Install with webdriver-manager update --standalone
So I still need to download the selenium standalone server manually?
Or maybe I missed some configuration here?
Protractor is a wrapper around WebDriverJS.
It's a nodejs program that interacts with Selenium Server and specific Browser drivers (e.g. ChromeDriver, IEDriver).
So, without using selenium server (at least for IE), you cannot run tests written with protractor. Test scripts send commands to the Selenium Server, which in turn then communicates with the browser driver. See this for a description of the architecture.
In a nutshell, without having started a Selenium server instance beforehand, nothing will happen.
You can run Protractor without Selenium by specifying
directConnect: true
in your respective Protractor configuration file (e.g. protractor.conf.js).

Use npm protractor webdriver-manager to start selenium server at a different port

I am trying to run E2E tests for an angular application using protractor. I use the command ./node_modules/protractor/bin/webdriver-manager to start my selenium server. However the default selenium server location is localhost:4444/wd/hub, but localhost:4444 is already used on my machine and this is difficult to change. How do I start a selenium server at a port other than 4444?
Use below command :
webdriver-manager start --seleniumPort XXXX

Can not run End to End Test in Angular Seed

I am trying to follow the AngularJS Fundementals series on PluralSight. The instructor has downloaded and opened up Angular Seed, and runs the e2e-test.sh file with no problems.
I use the regular Windows Command window, and so I attempt to follow his lead but with e2e-test.bat.
But it isn't working for me, here is what I get:
Have you installed Karma? http://karma-runner.github.io/0.10/index.html
npm install -g karma
If this installs ok you should be able to check the version from the command line:
karma --version
I'm taking the same course and I ran into the same issue.
You need to use the Node.js command prompt instead of the Windows Command Prompt.
If you have Windows 8, go to the Start page (hit the Windows key), then type "Node".
The Node.js command prompt will be one of the results.
Then from there you can install karma, karma junit reporter, etc. and run the test scripts.

Resources