我正在尝试使用量角器来测试包含 monaco 编辑器的代码,但找不到如何以编程方式编辑代码。
这是我的测试
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');
}
}
帮助了解如何在摩纳哥编辑代码或将代码粘贴到摩纳哥。