ryx / testcafe-browser-provider-nightmare

Testcafe browser provider for the nightmare browser automation library
MIT License
26 stars 5 forks source link

Tests failing in nightmare #7

Open gerardus1995 opened 7 years ago

gerardus1995 commented 7 years ago

Is there any reason why test that i got already working in chrome when i test it in nightmare i get "The specified selector does not match any element in the DOM tree."?

AlexanderMoskovkin commented 7 years ago

Hi, it can be some electron-specific thing. So, it's hard to determine the reason without the example. You can try to investigate it deeply (for example write to console outer html of some elements in the test to see what happens)

gerardus1995 commented 7 years ago

I just cloned the basic example that testcafe provides us with and tried nightmare browser on it. It fails as well on nightmare but works on chrome. How can i see if theres something wrong with my nightmare or what should i do to fix this? THanks.

AlexanderMoskovkin commented 7 years ago

What the error do you see?

gerardus1995 commented 7 years ago

Using locally installed version of TestCafe. Running tests in:

gerardus1995 commented 7 years ago

And in chrome i got: Running tests in:

AlexanderMoskovkin commented 7 years ago

Thanks for the clarification. The problem is related to native browser dialogs handling (alert, confirm, promt, beforeunload). We've found that Nightmare performs some modifications with these dialogs in their preload.js script. It breaks TestCafe behavior in some cases. We will find a way to fix it

gerardus1995 commented 7 years ago

Okey thanks for the explanation.

gerardus1995 commented 7 years ago

And in this case (not the same error than before) what could be the problem?

On nightmare:

Using locally installed version of TestCafe. Running tests in:

On chrome:

Using locally installed version of TestCafe. Running tests in:

It is a very simple test with only one assertion i dont understand why nightmare doesn't find the selectors.

AlexanderMoskovkin commented 7 years ago

It's too hard to determine the problem without a page example in this case

gerardus1995 commented 7 years ago

Okey then let me show you another example where it happens the same to me in this website "https://www.eltiempo.es/" where i get this in chrome:

Using locally installed version of TestCafe. Running tests in:

and this in nightmare:

Using locally installed version of TestCafe. Running tests in:

and the test code i'm using is this:

import { Selector } from 'testcafe'; import moment from 'moment'; //test suposing you are in .com website

fixture Getting Started .page https://www.eltiempo.es/;

test('check for the weather in barcelona', async t => { var email = 'testcafe'+moment().format('HHMMSS')+'@test.com'; await t .typeText(Selector('#inputSearch'), 'Barcelona') .click(Selector('.form_search_submit'));

await t
    .click(Selector('.m_search_results > li:nth-child(1)'));

await t
    .expect(Selector('#page > main > div.section_city > div > section:nth-child(1) > section > ol > li:nth-child(4) > p > span').innerText).eql('Barcelona')
    .click(Selector('#page > header > div.banner_actions > div > div > div.banner_actions_featured > div > div:nth-child(2) > a'));

await t
    .expect(Selector('#page > main > div.section_ski > div > section:nth-child(1) > article > div > p').innerText).eql('Estaciones españolas');

});

Thanks you very much.

AlexanderMoskovkin commented 7 years ago

Thanks for the example, we'll check it

gerardus1995 commented 7 years ago

Hey, have you been able to check something or find the issue here? Thanks!

AlexanderMoskovkin commented 7 years ago

Hi @gerardus1995,

I've checked your case. I've tried to run your page with nightmare (without testcafe). By default the page is opened in mobile view, because of the window size: 2017-04-07_1416

You can reproduce it if you run the test in the Chrome with not big window size.

In this case the target input is not visible, therefore testcafe can't click it. So you need to increase window size, for example you can do it via resizeWindow action:

await t.resizeWindow(1600, 800);
gerardus1995 commented 7 years ago

is there any way to set the window size allways to a certain dimesions so i dont have to put that line everywhere?

AlexanderMoskovkin commented 7 years ago

For now the only way to set the browser size in your case is using the t.resizeWindow command. To avoid code duplication you can do it in the fixture.beforeEach hook (see testcafe documentation).

Meanwhile, Nightmare allows to set the browser size via its constructor options. But it's necessary to add API for this in the plugin.

gerardus1995 commented 7 years ago

Thank you very much!

rahulmr commented 6 years ago

This is really cool feature. Like in protractor conf we can specify the window size as chromeOptions args or say in testcafe I can write testcafe 'firefox:headless,chromium:headless --no-sandbox' ./e2e/**/*.js
Is it possible to add something similar may be like testcafe 'nightmare --view-port 1024x680' ./e2e/*.js ?