UserService.ts
*** Settings ***
Suite Setup Login to Application
Suite TearDown Logout and Close The Browser
Resource import all required resource files
***Test Cases ***
Sample Test Case To Create Data for Multiple countries
Select Country USA #here am hard coding the country value instead i want to pass it while run time
Enter all required data
Click Submit
#sample resource file that has the keyword for selecting Country Drop down and fill other details
*** Keywords ***
Select Country
[Arguments] ${value}
Select From List By Label ${locator} ${value}
Input Text locator text value
这是我的模特英雄。
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Response } from "@angular/http";
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
import { Hero } from '../hero';
import { HeroesComponent } from './heroes.component';
export * from './user.service';
@Injectable()
export class UserService {
readonly rootUrl = 'URL ';
constructor(private http: HttpClient) { }
registerUser() {
const body: Hero = {
FirstName: '13',
LastName: '5451',
Password: '24',
Email: 'djfh@gmail.com',
Phone: '521212121',
CountryId: '1'}return this.http.post(this.rootUrl + 'SignUp/Register', body);}}
这是Heros.component
export class Hero {
FirstName: string;
LastName: string;
Email: string;
Password: string;
Phone: string;
CountryId: string;
}
用户服务我想调用onOnit方法,因此它将首先调用该方法,并借助Web API将数据保存到服务器。 在这里,我正在ngOnInit()中调用方法,因此它同样会引发错误。
谢谢。