有没有办法慢慢使用量角器编写Angular E2E测试,以便我可以观察到发生了什么?
我的问题是如何在docker容器中运行google chrome进行e2e测试.我创建了一个Dockerfile官方Jenkins图像,但是当尝试运行谷歌浏览器时,它会崩溃并显示错误:
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap (core dumped)
Run Code Online (Sandbox Code Playgroud)
Jenkins docker镜像使用Debian jessie.
我可以用--headless旗帜运行谷歌浏览器,不需要X服务器.
这是我的docker文件:
詹金斯官方形象:
一个人使用来自docker的GUI运行google chrome:
我的第一种方法是使用xvbf,但使用--headlessflag 时过程更简单.
我可以使用相同的安装命令在Ubuntu服务器上运行chrome,但是在docker中它会失败.
在其他意图之后,我使用了--no-sandboxflag,但是docker图像显示了下一个错误.
[0427/180929.595479:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0427/180929.595537:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
其实我运行了这个命令:
google-chrome-stable --headless --disable-gpu --no-sandbox http://www.google.com
在量角器端到端测试中,我想检查一个元素是否存在使用元素(by.css(...)),我的代码:
var myElement = element(by.css('.elementClass'));
expect(myElement).toBeUndefined;
Run Code Online (Sandbox Code Playgroud)
该测试失败,它说:
Expected { locator_ : { using : 'css selector', value : 'div[ng-switch-
when="resultNav"]' }, parentElementFinder_ : null, opt_actionResult_ :
undefined, opt_index_ : undefined, click : Function, sendKeys : Function,
getTagName : Function, getCssValue : Function, getAttribute : Function, getText
: Function, getSize : Function, getLocation : Function, isEnabled : Function,
isSelected : Function, submit : Function, clear : Function, isDisplayed :
Function, getOuterHtml : Function, getInnerHtml : Function, toWireValue :
Function } to …Run Code Online (Sandbox Code Playgroud) 我想将Protractor与Yeoman生产的脚手架相结合.我按照教程进行操作,其中旧版本scenario-runner用于设置e2e测试(通过grunt).
我想升级我的脚手架并改用Protractor.
有什么想法吗?
因为我可以使用selenium-standalone和xpath来测试应用程序.但测试SPA可能会在某个时候发生挑战.
但是,例如angularjs的团队为此提供了量角器.
我可以看到量角器背后的原因是量角器等到angularjs将被加载并且还有更多的功能:
Protractor提供了一些新的定位器策略和功能,这对于AngularJS应用程序的自动化非常有用.示例包括:waitForAngular,By.binding,By.repeater,By.textarea,By.model,WebElement.all,WebElement.evaluate等.
所以,问题是:在Vuejs中进行e2e测试是否是任何工具或最佳实践?
UPD:随时发布指向教程的链接,示例以及关于vue.js中e2e-testing的一切.谢谢.
我通过运行以下命令开始我的量角器测试:
protractor protractor.conf.js --params.baseUrl=http://www.google.com --suite all
Run Code Online (Sandbox Code Playgroud)
我想运行一个'before launch'函数,它依赖于一个参数(在本例中是baseUrl).这有可能吗?
exports.config = {
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
seleniumPort: 4455,
suites: {
all: 'test/*/*.js',
},
capabilities: {
'browserName': 'firefox'
},
beforeLaunch: function() {
console.log('I want to access my baseUrl parameter here: ' + config.params.baseUrl);
},
onPrepare: function() {
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('output/xmloutput', true, true));
}
};
Run Code Online (Sandbox Code Playgroud)
如果我运行它我得到一个ReferenceError因为没有定义配置.我该怎么办?这甚至可能吗?
我想登录并localStorage在客户端设置令牌(具体jwt)
cy.request如赛普拉斯文档中所建议的,如何使用它来实现此目的?
我使用Angular环境变量来配置API端点:
.\src\environments:
environment.ts
environment.test.ts
environment.prod.ts
Run Code Online (Sandbox Code Playgroud)
环境文件包含以下设置,这些设置对于本地开发和CI服务器是不同的:
export const environment = {
...
apiUrl: "https://api.sample.com"
};
Run Code Online (Sandbox Code Playgroud)
当我需要构建或启动应用程序时,这工作正常.我可以简单地指定环境参数:
ng serve --environment=test
Run Code Online (Sandbox Code Playgroud)
......但是在运行e2e Protractor测试时似乎无法设置特定的环境.以下命令只是忽略了环境(根据此注释似乎是预期的).始终使用默认环境:
ng e2e --environment=test // same as `ng e2e`
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以使用特定环境运行测试?
我使用这个yeoman生成器:https: //github.com/Swiip/generator-gulp-angular
它安装了三个测试应用程序:Jasmine,Karma,Protractor根据这篇文章(我应该使用Protractor或Karma进行端到端测试吗?),我应该使用:Karma用于例如单个控制器的小测试.Protactor如果我想测试整个应用程序并模拟用户浏览我的应用程序.根据这篇博客(http://andyshora.com/unit-testing-best-practices-angularjs.html),我将使用Jasmine进行单元测试,使用Karma进行端到端集成测试.
我猜Jasmine是编写测试的语言,另外两个执行代码,这是正确的吗?另外,如果我从未写过一个更重要的是先学习/专注的测试?
我只想切换运行一个测试,所以不必等待其他测试来查看一个测试的结果。
目前,我注释掉了其他测试,但这确实很烦人。
有没有一种方法可以切换仅运行一个测试Cypress?
e2e-testing ×10
protractor ×6
angularjs ×4
cypress ×2
javascript ×2
testing ×2
angular ×1
browser ×1
docker ×1
gruntjs ×1
jasmine ×1
jenkins ×1
karma-runner ×1
selenium ×1
vue.js ×1