I have written some tests for my app in selenium. I run them locally and on our GitLab-CI. locally they work, but on the CI they fail suddenly (without me having changed something relevant afaik). What makes me scratch my head is, the fact, that the beforeAll not seems to be ran to the end.
Consider this:
let driver;
const options = new Options();
if (testConfig.headless) {
options.addArguments('-headless');
}
describe('my app', () => {
beforeAll(async done => {
console.log('beforeAll');
try {
driver = await new Builder()
.forBrowser('firefox')
.setFirefoxOptions(options)
.build();
} catch (e) {
console.log('error', e);
}
console.log(!driver ? 'driver is not' : driver is');
done();
});
});
beforeEach(async done => {
await driver.get(/* my apps path */);
done();
});
Result on de CI: Every test fails in beforeEach
because driver
is undefined
. But the beforeAll
only reports 'beforeAll'. the log in the end does not says nothing. So the beforeAll
function seem to fail, but silently and the script does continue anyway. Any Ideas how I can fix or even debug this?
My dependencies
"devDependencies": {
"geckodriver": "^1.20.0",
"jasmine": "^3.6.3",
"selenium-webdriver": "^4.0.0-alpha.7",
CodePudding user response:
The reason was, in contradiction to the above example, the browser wasn't started in headless mode. My fault. But still, a very crappy behavior not to say anything. I leave this here, if anyone is facing the same.