我们在无头模式下使用量角器进行e2e测试。
我们想要先测试身份验证。其行为类似于上面的:
1/用户在浏览器上点击链接2/服务器将检查该用户是否已通过身份验证2.1如果用户已通过身份验证,主页将显示2.2如果未通过,用户将通过
这里的问题是,javascript不会被执行。我尝试添加一些标志,但没有任何区别。
exports.config = {
allScriptsTimeout: 20000,
specs: [
'./e2e/account/**/account.spec.ts',
],
capabilities: {
'browserName': 'firefox',
'marionette': true,
'moz:firefoxOptions': {
args: [ "--headless"],
firefox_binary: '/opt/firefox/firefox',
binary_: '/opt/firefox/firefox',
},
acceptInsecureCerts: true,
javascriptEnabled: true,
},
directConnect: true,
baseUrl: 'http://demop-staging-ppd.com/',
framework: 'mocha',
// SELENIUM_PROMISE_MANAGER: false,
mochaOpts: {
reporter: 'spec',
slow: 3000,
ui: 'bdd',
timeout: 720000
},
beforeLaunch: function() {
require('ts-node').register({
project: 'tsconfig.e2e.json'
});
},
onPrepare: function() {
browser.driver.manage().window().setSize(1280, 1024);
// Disable animations
// @ts-ignore
browser.executeScript('document.body.className += " notransition";');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const chaiString = require('chai-string');
chai.use(chaiString);
// @ts-ignore
global.chai = chai;
},
useAllAngular2AppRoots: true
};等级库文件:
before(async () => {
await browser.waitForAngularEnabled(false);
});
it('should content display content ', async () => {
await browser.get('/');
browser.sleep(5000);
const content= await browser.getPageSource();
console.log(content)
});我对任何建议都持开放态度,并可以为您提供任何其他信息。
更新
我像上面一样更改了我的配置文件,以尝试在我的浏览器上启用javascript。它可以在本地运行,但当我在docker image上尝试时,它不能
capabilities: {
'browserName': 'firefox',
'marionette': true,
'moz:firefoxOptions': {
args: ["--headless"],
firefox_binary: '/opt/firefox/firefox',
binary_: '/opt/firefox/firefox',
"prefs": {
"javascript.options.showInConsole": true,
"javascript.enabled": true
},
"log": { "level": "trace" }
},
acceptInsecureCerts: true,
acceptSslCerts: true,
},发布于 2020-01-13 17:31:33
multiCapabilities: [ { browserName: 'firefox', firefoxOptions: { args: ['--headless'] }, 'moz:firefoxOptions': { args: [ '--headless' ] } } ]请检查一下这个
使用webdriver-manager执行。使用directConnect时,您将出现权限被拒绝的错误。
我还检查了linux PC。这个很好用

https://stackoverflow.com/questions/59713327
复制相似问题