-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


Java Selenium

, 05 2017 . 21:33 +
: , - . , ( ). , , LEAN- - -. ?

- .

: , , , , Enterprise .



- , - , , . ?

: .

Headless Chrome: headless (.. ).

PhantomJS' :

This is the end https://t.co/GVmimAyRB5 #phantomjs 2.5 will not be released. Sorry, guys!

— Vitaly Slobodin (@Vitalliumm) April 13, 2017


, , , :
1) Chrome 59 ( beta) Chromium Browser
2) nodejs + npm

!

(, - , , . .)

, , headless-, . ( headless-, ?!) Chromium Browser Ubuntu:

sudo apt-get install chromium-browser


WebDriver', API, , Chromedriver. npm:

npm install chromedriver


, , JavaScript' (217 ). Nightwatch.js ( LinkedIn). Nightwatch.js . , Chromedriver . :

npm install nightwatch


( Nightwatch.js -> Chromedriver -> Headless Chrome):

-> Chromedriver ->

-?


Nightwatch nightwatch.json node_modules/nightwatch/bin.

. nightwatch.json , Chromedriver ( ) Chromium headless :

nightwatch.json
{
  "src_folders": ["tests"], //     
  "output_folder": "reports",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "",
  "globals_path": "globals.js", //   ,        

  "selenium": {
    "start_process": false //   , ..    Chromedriver 
  },

  "test_settings": {
    "default": {
      "selenium_port": 9515, //   Chromedriver   ("selenium_"       )
      "selenium_host": "localhost",
      "default_path_prefix" : "",

      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions" : {
          "args" : ["--no-sandbox", "--headless", "--disable-gpu"], //       headless-
          "binary" : "/usr/bin/chromium-browser" //     
        },
        "acceptSslCerts": true
      }
    }
  }
}

globals.js. . , Chromedriver :

globals.js
const chromedriver = require('chromedriver');

module.exports = {
  before: function(done) {
    chromedriver.start();

    done();
  },

  after: function(done) {
    chromedriver.stop();

    done();
  }
};

- . : ya.ru, - . , Nightwatch.js API , :

ya.js
module.exports = {
  'Test ya.ru': function(browser) {
    const firstResultSelector = '.serp-list .organic__subtitle b';

    browser
      .url('http://ya.ru', () => {
        console.log('Loading ya.ru...');
      })
      .waitForElementVisible('#text', 5000)
      .execute(function() {
        document.getElementById('text').value = ', !';
      })
      .submitForm('form')
      .waitForElementVisible(firstResultSelector, 5000)
      .getText(firstResultSelector, result => {
        browser.assert.equal(result.value, 'm.habrahabr.ru');
      })
      .end();
  }
};

!

$ nightwatch --test tests/ya.js

[Ya] Test Suite
===================

Running: Test ya.ru
Loading ya.ru...
Element <#text> was visible after 70 milliseconds.
Warn: WaitForElement found 10 elements for selector ".serp-list .organic__subtitle b". Only the first one will be checked.
Element <.serp-list .organic__subtitle b> was visible after 1706 milliseconds.
Passed [equal]: m.habrahabr.ru == m.habrahabr.ru

OK. 3 assertions passed. (4.992s)



. , , , .

Java, Python', Selenium.

- .

:
1) Getting Started with Headless Chrome: developers.google.com/web/updates/2017/04/headless-chrome
2) Nightwatch.js API reference: nightwatchjs.org/api
3) Nightwatch.js: www.youtube.com/watch?v=794uaoenv_M
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/329660/

:  

: [1] []
 

:
: 

: ( )

:

  URL