How to make protractor work when using Cloud9?

I am new to Cloud9 and I am trying to use Protractor to test e2e. I am running angular -phonecat examples.

The error is as follows:

Using ChromeDriver directly... /home/ubuntu/workspace/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109 var template = new Error(this.message); ^ UnknownError: chrome not reachable (Driver info: chromedriver=2.10.267518,platform=Linux 3.14.13-c9 x86_64) at new bot.Error (/home/ubuntu/workspace/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:109:18) .. 

I installed a chrome recorder. The only thing to do is install Chrome on cloud9 and run the tests?

Thank you in advance,

amuses Haytham

+6
source share
3 answers

I am a fan of webase IDE and Cloud9 is one of the best. Here you can install Xvfb, chrome and Protractor to run AngularJS end-to-end Cloud9 automated testing

Open a terminal (xvfb already installed on c9.io)

  • install X11 fonts

     $ sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic 
  • install the last chrome

     $ wget -q -O - \ https://dl-ssl.google.com/linux/linux_signing_key.pub \ | sudo apt-key add - $ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" \ >> /etc/apt/sources.list.d/google-chrome.list' $ sudo apt-get update $ sudo apt-get install -y google-chrome-stable 
  • install protractor

     $ npm install -g protractor 
  • update webdriver

     $ webdriver-manager update 
  • use --no sandbox with chrome

    Since c9.io is running inside the container, this parameter is necessary.
    Update protractor conf.js to pass chrome option

     capabilities: { browserName: 'chrome', 'chromeOptions': { args: ['--no-sandbox'] } } 

perform protractor test on headless chrome

  • Run webdriver using xvfb (headless)

     $ xvfb-run webdriver-manager start 
  • run the test on another terminal

     $ protrator conf.js 

From http://blog.maduma.com

+11
source

It is not possible to "install" browsers on cloud9 to run end-to-end browser-based test scripts. The selenium web driver hopes to download chrome, which runs the tests, but throws an error, because this is not what can be found in the cloud9 development environment.

If you are configured to run these tests in an online IDE, such as cloud9, the only option is to use a dumb browser such as phantomJS, but pay attention to the protractor docs.

We recommend using PhantomJS for testing with Protractor. There are many reports of problems with PhantomJS crashing and behaving differently from real browsers.

I would recommend downloading your application locally and running extensive E2E tests in browsers that your users will actually use to access your application.

Another option is to use something like Saucelabs ( https://saucelabs.com/ ) for automated cloud cross-browser testing; this will require some configuration in the protractor_conf.js file. Please note that there may be additional costs associated with cloud testing.

0
source

I just checked this and it works for me on my chromonics. It contains all the steps necessary to complete the first page of https://docs.angularjs.org/tutorial , including setting protractor tags.

 create new blank workspace run these commands rm -rf * .c9 git clone --depth=16 https://github.com/angular/angular-phonecat.git cd angular-phonecat nvm install 7 nvm alias default node npm install minimatch sudo npm install npm -g edit this file angular-phonecat/package.json "start": "http-server ./app -a $IP -p $PORT -c-1" run these commands npm start click 'Share' browse to url next to 'Application' yay! the phonecat webapp should be running! karma add these lines to karma.conf.js hostname: process.env.IP, port: process.env.PORT edit package.json "test": "karma start karma.conf.js --no-browsers" run this command npm test browse to http://<projectName>.<cloud9User>.c9.io:8081 go forth and test! protractor run these commands sudo apt-get update sudo apt-get install -y xvfb wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' sudo apt-get update sudo apt-get install -y google-chrome-stable edit protractor.conf.js capabilities: { 'browserName': 'chrome', 'chromeOptions': { args: ['--no-sandbox'] } } run these commands npm install -g protractor sudo webdriver-manager update xvfb-run webdriver-manager start edit protractor.conf.js baseUrl: 'http://' + process.env.IP + ':' + process.env.PORT + '/' seleniumAddress: 'http://127.0.0.1:4444/wd/hub' run these commands protractor protractor.conf.js 
0
source

Source: https://habr.com/ru/post/979305/


All Articles