Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Protractor work while using Cloud9?

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

The error is the folowing:

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 the chromedriver. The only thing is how to install the actual Chrome on cloud9 and run the tests?

Thank you in advance,

cheers, Haytham

like image 250
user3696825 Avatar asked Dec 09 '14 02:12

user3696825


1 Answers

I'm a fan of webase IDE and Cloud9 is one of the best. Here a way to install Xvfb, chrome and Protractor for doing AngularJS end-to-end automated testing on Cloud9

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 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 option with chrome

    As c9.io is running inside container this option is needed.
    Update protractor conf.js to pass the option to chrome

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

run protractor test on headless chrome

  • start webdriver with xvfb (headless)

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

    $ protrator conf.js
    

From http://blog.maduma.com

like image 99
user3277560 Avatar answered Oct 29 '22 16:10

user3277560