我在maven有一个java项目,我知道maven把东西常规使用
一切都在测试/通常是单元测试.但是,如果我想引入集成测试和E2E测试呢?我该如何放入正确的文件夹结构?组织这些的正确方法是什么?
可能是这样的:
?
但这样做会假设src/test/java指的是单元测试.我宁愿明确指定
TestCafe克服了哪些问题证明它适用于Selenium?是否值得将旧的测试套装移植到TestCafe?
automated-tests web-testing selenium-webdriver e2e-testing testcafe
我正在使用jest-puppeteer来运行我的网络测试.如果我运行我在一个文件中定义的测试,一切都很完美.
describe('user', () => {
jest.setTimeout(12000);
beforeEach(async () => {
await page.setViewport({width: 1200, height: 2000});
await page.goTo('http://localhost:3000');
});
it('test 1', async () => {
//my test steps
});
it('test 2', async () => {
//my test steps
});
});
Run Code Online (Sandbox Code Playgroud)
但是,如果我在自己的文件中运行每个测试,我会收到错误.
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'addExpectationResult' of undefined
Run Code Online (Sandbox Code Playgroud)
文件1
describe('user', () => {
jest.setTimeout(12000);
beforeEach(async () => {
await page.setViewport({width: 1200, height: 2000});
await page.goTo('http://localhost:3000');
});
it('test 1', async () => {
//my test steps
});
});
Run Code Online (Sandbox Code Playgroud)
文件2
describe('user', () …Run Code Online (Sandbox Code Playgroud) 有类似的问题(下面链接)但没有解决这个问题.我正在为一个离子项目编写量角器测试.当Ionic Loading对话框出现并消失时,我需要执行测试.
我已经用应用程序的骨干和需要进行的测试创建了一个repo.解决这个问题并解决问题(我在下面描述了这个问题):https://github.com/TmanTman/StackoverflowQ.只需在conf.js中调整适用于您系统的Chrome的路径即可.
要模拟异步离子加载对话框,我只需将其添加到空白离子项目中的控制器:
$interval( function() {
$ionicLoading.show({
template: 'Async ionicLoading',
duration: 5000
});
}, 5000 , 1);
})
Run Code Online (Sandbox Code Playgroud)
我需要让量角器等待对话框出现,做一些测试,等待对话框消失,然后再进行一些测试.我在测试文件中的最新尝试是:
it('should only test when ionicLoading appears', function() {
browser.wait(function(){
return element(by.css('.loading-container.visible.active')).isPresent();
}, 10000);
var ionicLoadingText = element(by.css('.loading-container.visible.active')).getText();
expect(ionicLoadingText).toEqual('Async IonicLoading');
})
it('should only test once ionicLoading disappears', function() {
browser.wait(function() {
var deferred = protractor.promise.defer();
var q = element(by.css('.loading-container.visible.active')).isPresent()
q.then( function (isPresent) {
deferred.fulfill(!isPresent);
});
return deferred.promise;
});
expect(1).toEqual(1);
})
Run Code Online (Sandbox Code Playgroud)
我试图避免使用同步睡眠功能,因为我的代码是高度异步的.我尝试了无数的变化,但我无法让它发挥作用.我用于信息的链接包括:
我一直在将我的应用程序从4迁移到6,我无法为我的e2e测试执行我的代理脚本.脚本列表如下所示:
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:tst1": "ng serve --proxy-config config/proxy/proxy.tst1.json",
"start:tst5": "ng serve --proxy-config config/proxy/proxy.tst5.json",
...
"test:watch": "ng test",
"lint": "ng lint --type-check true",
"e2e": "ng e2e",
"e2e:tst1": "ng e2e --proxy-config config/proxy/proxy.tst1.json",
"e2e:tst5": "ng e2e --proxy-config config/proxy/proxy.tst5.json",
},
Run Code Online (Sandbox Code Playgroud)
我不明白的是,启动命令(ng serve)工作得非常好npm run start:tst5.但是,当我尝试执行e2e测试时,npm run e2e:tst5它会抛出错误:Unknown option: '--proxyConfig'.
我的angular.json中的配置如下所示:
...
"lmsbo-bo-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": { …Run Code Online (Sandbox Code Playgroud) 我正在使用量角器进行测试.99%的时间没有必要真正看到浏览器,测试需要很长时间,而我们感兴趣的是最终结果.有没有办法隐藏为测试打开的浏览器(例如在后台运行)?
我正在开发一个AngularJS应用程序,我喜欢用Protractor(e2e测试)测试它.我正在遵循这个优秀的指南,但我被困在第5步(下载并启动selenium服务器),因为在古巴生活,当我尝试安装Selenium服务器时,我得到403错误(这是出于政治问题,到不详细说明).
问题是如何手动或以其他方式安装它.问候,希望有人可以帮助我.
编辑:
当我跑步时,node_modules/protractor/bin/webdriver-manager update我得到(相关部分):
downloading https://chromedriver.storage.googleapis.com/2.14/chromedriver_linux64.zip...
Error: Got code 403 from https://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar
selenium-server-standalone-2.45.0.jar downloaded to /webapps/webvisor/client/node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar
Error: Got code 403 from https://chromedriver.storage.googleapis.com/2.14/chromedriver_linux64.zip
chromedriver_2.14.zip downloaded to /webapps/webvisor/client/node_modules/protractor/selenium/chromedriver_2.14.zip
Run Code Online (Sandbox Code Playgroud) 例如,我有这个应用程序的HTML代码:
<div class="swipe-cover" ng-swipe-left="func()"></div>
Run Code Online (Sandbox Code Playgroud)
这样的测试:
it('test', function() {
browser.executeScript( 'angular.element(".swipe-cover").triggerHandler("swipeleft")' );
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
如果我使用'click'insteaf'swipeleft',它就可以了.
如何为e2e测试触发'swipeleft'事件?
如何编写需要与文件Input DOM元素交互的e2e流测试?
如果它是文本输入,我可以与它交互(检查值,设置值)等作为它的DOM组件.但是如果我有一个文件输入元素,我猜测交互是有限的,直到我可以打开对话框来选择文件.我无法前进并选择我要上传的文件,因为对话框是本机的而不是某些浏览器元素.
那么我如何测试用户是否可以从我的网站正确上传文件?我正在使用赛普拉斯编写我的e2e测试.
我是 Cypress 的新手,有一个小问题,我需要一些帮助。
我的应用程序中有一个输入字段,允许我输入名称。此名称必须是唯一的,并且不得与系统中已有的名称相同。
我目前正在通过以下方式单击此输入字段:
cy.get('input[type="text"].form-control')
如果我使用该cy.type()命令,这将始终输入所提供的相同值,但每次测试运行时,我都想分配一个不同的值。
// Fill in some details of a new class to proceed with creation
cy.get('.pull-left > h4').contains('Add a new class')
cy.get('input[type="text"].form-control') // Clicks on the field
// Some code to go here to create a random string and use what was created and
type this into the field above
Run Code Online (Sandbox Code Playgroud)
预期
创建一个函数,该函数允许生成一个随机字符串,然后通过普通的 cypress 命令将其输入到输入字段中。
e2e-testing ×10
protractor ×5
angularjs ×2
cypress ×2
javascript ×2
web-testing ×2
angular ×1
angular-e2e ×1
angular6 ×1
ionic ×1
java ×1
jestjs ×1
maven ×1
puppeteer ×1
selenium ×1
swipe ×1
testcafe ×1
testing ×1
unit-testing ×1
webtest ×1