1
我正在嘗試使用量角器來測試包含摩納哥編輯器的代碼,並且無法找到如何以編程方式編輯代碼的方法。如何使用量角器在摩納哥編輯器中插入代碼?
這是我的測試
import {CodelabPage} from './app.po';
import {browser, element, by} from 'protractor';
describe('codelab App', function() {
let page: CodelabPage;
beforeEach(() => {
page = new CodelabPage();
});
it('should display message saying app works',() => {
page.navigateTo();
page.openMilestone(1);
page.openExercise('TypeScript');
browser.pause(2000);
page.editCode('Dog.ts', `HopHeyLalalay`);
browser.pause();
}
);
});
這是我的職能
import {browser, element, by} from 'protractor';
import {By} from "protractor/built/index";
export class CodelabPage {
navigateTo() {
return browser.get('/');
}
getMilestoneDescriptionText() {
element(by.css('.milestone')).click();
return element(by.css('.description')).getText();
}
getElementText(nameElement) {
return element(by.css(nameElement)).getText();
}
openMilestone(index) {
return element(by.cssContainingText('.milestone', index)).click();
}
openExercise(text) {
return element(by.cssContainingText('.exercise', text)).click();
}
editCode(filename: string, code: string) {
return element(by.css('.monaco-editor-background textarea'))
.sendKeys('njnj');
}
}
幫助瞭解如何在摩納哥編輯代碼,或只是粘貼在摩納哥的代碼。