我需要使用cypress测试angularjs应用程序的下拉列表。
我需要单击一个下拉列表,然后从下拉列表中选择或单击一个项目。我想下面这是因为在第二个get()方法的ID号不断变化作为它的动态生成的工作了一个实例,但没有其他时间。这不是带有html中选项的标准选择。
1)无论如何,是否可以在每个选项上设置唯一属性,然后选择所需的选项,还是可以仅基于列表项的描述进行选择?我怎样才能做到这一点?
2)是否有以下正确的下拉列表测试方法?我敢肯定还有比这更好的方法吗?
请谁能帮忙
cy.get('[name="countries"]').click().get.('[id="selection_option_375"]').click()
Run Code Online (Sandbox Code Playgroud)
DOM
<md-select ng-model="target.countryType" name="countries" ng-required="requiredData.AssertRequiredFields" ng-change="oncountryTypeChanged($event)"
md-container-class="large" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" tabindex="0" aria-disabled="false"
role="listbox" aria-expanded="false" aria-multiselectable="false" id="select_297" aria-owns="select_container_298" aria-required="true"
required="required" aria-invalid="true" aria-label="country type" style=""><md-select-value class="md-select-value md-select-placeholder"
id="select_value_label_288">
<span>country type</span><span class="md-select-icon" aria-hidden="true"></span>
</md-select-value>
<div class="md-select-menu-container large" aria-hidden="true" id="select_container_298"><md-select-menu class="_md"><md-content class="_md md-no-flicker">
<!-- ngRepeat: countryType in refData.countryDetails.countryType.Items --><md-option ng-repeat="countryType in refData.countryDetails.countryType.Items" ng-value="countryType" tabindex="0" class="ng-scope md-ink-ripple" role="option" aria-selected="false" id="select_option_369" aria-checked="true" value="[object Object]" style=""><div class="md-text ng-binding">
Country one
</div></md-option><md-option ng-repeat="countryType in refData.countryDetails.countryType.Items" ng-value="countryType" tabindex="0" class="ng-scope md-ink-ripple" role="option" …Run Code Online (Sandbox Code Playgroud) 我需要在文本后加一条虚线。虚线应该一直到行尾。在下面的示例中,在组织/机构文本之后,虚线应开始并持续到行尾。使用下面的代码,我也得到了文本下方的虚线,这不是我想要的。
Organisation/Agency.................................................
Run Code Online (Sandbox Code Playgroud)
我试过如下。
Organisation/Agency.................................................
Run Code Online (Sandbox Code Playgroud)
.horizontal_dotted_line {
border-bottom: 1px dotted black;
width: 200px;
}Run Code Online (Sandbox Code Playgroud)
但我得到的输出是
Organisation/Agency
.................................................
Run Code Online (Sandbox Code Playgroud)
我需要的输出是组织/机构......................................
我必须使用 cypress 对 angularjs 应用程序进行端到端测试。
我有两个相同输入元素的实例。它们具有相同的 ng-model、class 和 name。我们已经获得了由应用程序动态生成的唯一 ID,每次页面加载或在不同机器上测试时,该 ID 都不能相同。
作为下面的示例,有两个具有相同名称的输入元素,但我需要相同的文本出现在两个输入元素上。当我使用以下命令时,cypress 抱怨两个同名实例。如何在具有相同名称的两个输入元素上键入相同的文本“Hello world”?
cy.get('input[name=description]').type('Hello World')
Run Code Online (Sandbox Code Playgroud) 我刚刚开始学习Angular 5,只需单击按钮即可打开一个对话框。应用程序无法构建,出现的错误是“ Dashboardcomponent类型上不存在错误ts2339属性对话框”,然后我安装了角形材料和cdk。编译时仍然会出现相同的错误。而在html页面(localhost:4200)上,我得到的错误是“无法读取未定义的属性” open”。如何获取对话框并打开对angular的工作?
打字稿:
import { Component, OnInit } from '@angular/core';
import { WebapiService } from '../providers/webapi.service';
import { MatDialog, MatDialogRef } from '@angular/material';
import { ServerDialogComponent } from '../server-dialog/server-dialog.component';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
constructor(private webApi: WebapiService) { }
ngOnInit() {
}
openServerDialog() {
const serverDialogRef = this.dialog.open(ServerDialogComponent, {
width: '250px',
data: { serverlist: this.webApi.getServerList() }
});
}
}
Run Code Online (Sandbox Code Playgroud)
的HTML:
<div class="main-content">
<div class="container-fluid">
<button mat-fab color="warning" (click)="openServerDialog()">open</button>
</div> …Run Code Online (Sandbox Code Playgroud)