在使用protractor.js为Angular 2应用程序编写测试用例时,如果我想让element(by.model("xyz.test"))它总是给出失败,说明角度没有定义.
知道如何解决这个问题吗?
我想为我的 Angular 应用程序设置一些端到端测试,这需要使用 MSAL 库来对一些下游服务进行身份验证。当我尝试在本地运行 e2e 测试时,MSAL 库强制我使用用户名/密码进行身份验证。
这是一个问题,因为我们的 CI/CD e2e 测试不应该有任何人为干预;因此,我正在寻找一种方法来绕过 MSAL 身份验证或设置服务帐户进行登录。不幸的是,围绕 Angular 的 MSAL 的文档并不多(尤其是在 e2e 测试方面),但这似乎是其他人可能遇到的常见问题。
我试图从我们的 app.module.ts 文件中禁用 MsalModule 但是当我尝试运行应用程序时仍然提示我登录。我还看到一些文章试图以编程方式登录,但这对我们不起作用,因为从技术上讲,MSAL 不是我们能够接触的 Angular 组件。
app.module.ts:
@NgModule({
...
imports: [
...
MsalModule.forRoot({
clientID: '<client_id>',
authority: <microsoft_authority_url>,
validateAuthority: true,
redirectUri: "http://localhost:4200/",
cacheLocation : "localStorage",
postLogoutRedirectUri: "http://localhost:4200/",
navigateToLoginRequestUrl: true,
popUp: true,
consentScopes: [ "user.read"],
unprotectedResources: ["https://www.microsoft.com/en-us/"],
protectedResourceMap: protectedResourceMap,
logger: loggerCallback,
correlationId: '1234',
level: LogLevel.Info,
piiLoggingEnabled: true
})
],
entryComponents: [SaveDialogComponent,
GenericDialog, MassChangeDialogComponent],
providers: [TitleCasePipe,
{provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: …Run Code Online (Sandbox Code Playgroud) [17:05:22] I/launcher – Running 1 instances of WebDriver
[17:05:22] I/direct – Using ChromeDriver directly… [17:05:22] E/direct – Error code: 135
[17:05:22] E/direct – Error message: Could not find update-config.json. Run ‘webdriver-manager update’ to download binaries.
[17:05:22] E/direct – Error: Could not find update-config.json. Run ‘webdriver-manager update’ to download binaries. at Direct.getNewDriver (C:automationDemoprotractor-jasmine-typescriptnode_modulesprotractorbuiltdriverProvidersdirect.js:63:31) at Runner.createBrowser (C:automationDemoprotractor-jasmine-typescriptnode_modulesprotractorbuiltrunner.js:195:43) at q.then.then (C:automationDemoprotractor-jasmine-typescriptnode_modulesprotractorbuiltrunner.js:339:29) at _fulfilled (C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:834:54) at self.promiseDispatch.done (C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:863:30) at Promise.promise.promiseDispatch (C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:796:13) at C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:556:49 at runSingle (C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:137:13) at flush (C:automationDemoprotractor-jasmine-typescriptnode_modulesqq.js:125:13) at _combinedTickCallback (internal/process/next_tick.js:131:7)
[17:05:22] E/launcher …Run Code Online (Sandbox Code Playgroud) 我们有一个庞大的项目,我们编写了许多测试用例,以涵盖e2e功能测试用例中的许多实际场景用户行为。
随着测试的进行,它会进行大量的调用以完成测试用例。当我们在酱料实验室中使用其他浏览器时,它会倍增5-9倍。
我要模拟所有其余的调用,这样就不会对实际服务器进行任何真正的调用,但是会在内部对其进行处理。它用于功能e2e测试,而不是单元测试,因为我们使用jasmine模拟了所有单元测试spyOn。
我已经探索json-server和$httpBackend量角器。子服务器不合适,因为它不能很好地处理应用程序的发布,放置,删除呼叫。如果是$ httpBackend
我已经看完了这篇文章,它涉及的是andularJs应用程序而不是angular应用程序,也涉及到有关angularJs的单个rest调用模拟,而不是所有rest调用。
还为angularjs看了这个angularjs 多重模拟,也为angularjs 看到了它,而不是angularjs,看起来像这样更改了查询参数的原始REST URL。
我们有一个应用程序,在本地进行测试会显示无效的SSL证书警告。通常,我只添加一个异常并继续处理。但是,量角器有没有忽略这一点?
我已经看到了硒中的一些功能,其中可以忽略SSL,但是似乎在量角器中找不到任何功能。
element(by.className('cuppa-dropdown')).element(by.className('dropdown-list')).element(by.className('list-area')).element(by.tagName('li')).click();
Run Code Online (Sandbox Code Playgroud)
实际上,此元素在弹出窗口中。在无头模式下,它的工作状况还不错。但是由于我们需要通过内置vsts来自动化测试用例,因此我们需要以无头模式执行测试
失败:未知错误:元素在点( 863,343)上不可单击(会话信息:无头chrome = 63.0.3239.84)(驱动程序信息:chromedriver = 2.34.522940(1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform = Windows NT 10.0.16299 x86_64)
将不胜感激!
webdriver-manager cleanwebdriver-manager更新--ie32 --proxy http:// my-proxy:8080 --ignore_ssl
我的protractor.conf文件如下:
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'proxyType': 'manual',
'httpProxy': 'http://my-proxy:8080'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
Run Code Online (Sandbox Code Playgroud)
尝试首先通过以下方式进行测试ng e2e
: …
我在 Firebase 网络应用程序上使用 Cypress 进行 e2e 测试,并且我希望测试运行始终从未经身份验证的状态重新开始。
如何防止 Firebase Auth 会话在 e2e 测试运行中持续存在?
目前,我logout()在测试结束时有一个函数调用。但是如果在那之前测试失败,logout()通常不会被调用,我必须在下一次测试运行之前手动注销。
firebase e2e-testing firebase-authentication angular-e2e cypress
我正在尝试使用Protractor为我的Angular应用程序编写一些e2e测试。
我有一个id=my-btn想要单击的简单html按钮,使用:
$('#my-btn').click();
Run Code Online (Sandbox Code Playgroud)
不幸的是我遇到以下错误:
失败:脚本超时:11秒内未收到结果
来自:任务:Protractor.waitForAngular()-定位器:通过(css选择器,#my-btn)
Run Code Online (Sandbox Code Playgroud)(Session info: chrome=73.0.3683.75) (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.3 x86_64)
如果在点击之前我设置了:
browser.waitForAngularEnabled(false);
Run Code Online (Sandbox Code Playgroud)
那我就没有任何错误 问题在于这样做意味着:
Run Code Online (Sandbox Code Playgroud)* If set to false, Protractor will not wait for Angular $http and $timeout * tasks to complete before interacting with the browser. This can cause * flaky tests, but should be used if, for instance, your app continuously * polls an API with $timeout.
所以我想什么导致waitForAngular操作超时。
有没有办法检查仍然挂起的HTTP或超时? …
angular-e2e ×9
angular ×7
protractor ×6
e2e-testing ×5
angular-cli ×1
angular-mock ×1
angular-test ×1
asp.net-core ×1
cypress ×1
firebase ×1
model ×1
proxy ×1
typescript ×1