jeudi 9 mars 2017

How to load react components to phantomjs?

I create a Selenium Client:

var client = webdriverio.remote({
  desiredCapabilities: {
    browserName: 'phantomjs'
  }
});

But when I try to get any selector from my React app, it says it doesn't exists. I realize I should use react-addons-test-utils, but how to connect them in test?

describe('test React components', function(){
  before(function(){
    return client.init().url('http://localhost:8080/');
  });

  it('works as expected', () = > {
    return client
      .waitForVisible('.active-tab')
      .getText('.active-tab')
      .then(function(res, err) {
        return res.should.equal('Opened Tab!');
      });
  });

  after(function() {
    return client.end();
  });
});

It's not working. I get an error:

Error: element (.active-tab) still not visible after 500ms

I assume it's because I don't load React app to the PhantomJS DOM.

How can I achieve this?

Aucun commentaire:

Enregistrer un commentaire