在Angular中单击按钮时cypress不会导航到下一页

时间:2019-01-30 08:30:46

标签: cypress

我正在尝试用Cypress测试Angular中的Web应用程序构建。 单击按钮后,应导航到下一页。但是,这在赛普拉斯中不起作用。该应用程序运行正常。以下是html页面。

1 个答案:

答案 0 :(得分:-1)

<h2>Login</h2>
<div class="div1">
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
    <div class="form-group">
        <label for="username">Username</label>
        <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" />
        <div *ngIf="submitted && f.username.errors" class="invalid-feedback">
            <div *ngIf="f.username.errors.required">Username is required</div>
        </div>
    </div>
    <div class="form-group">
        <label for="password">Password</label>
        <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
        <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
            <div *ngIf="f.password.errors.required">Password is required</div>
        </div>
    </div>
    <div class="form-group">
        <button [disabled]="loading" type="submit" class="btn btn-primary">Login</button>
        <img *ngIf="loading" src="data:image/gif" />
        <a [routerLink]="['/register']" class="btn btn-link">Register</a>
    </div>
</form>
</div>

添加了html代码