本文介紹了我如何在 e2e 測試 Angular Protractor 的標(biāo)簽中添加文本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我如何在
標(biāo)簽中添加內(nèi)容以在量角器中進行 e2e 測試
how i add content in
tag for e2e testing in protractor
<html lang="en" dir="ltr">
<head>
<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="true">
<p>
<br type="_moz">
</p>
</body>
</html>
我試試這個,但這不起作用
i try this but this is not working
var p = element(by.css('.cke_editable p'));
p.sendKeys('This is a peragraph tag');
推薦答案
首先,在這種情況下,它是可編輯的主體 - 向它發(fā)送密鑰:
First of all, it is the body that's editable in this case - send keys to it:
var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');
一個更大的問題是,因為這是一個 CKeditor - 它通常嵌入在 iframe
中.這對我們來說實際上很重要——我們需要讓 webdriver 知道我們想要 切換到iframe
的上下文:
A bigger problem though is that, since this is a CKeditor - it's usually embedded in an iframe
. This is actually important for us - we need to let the webdriver know that we want to switch into the context of the iframe
:
browser.switchTo().frame(element(by.css("iframe.cke_wysiwyg_frame")));
var body = element(by.css('body.cke_editable'));
body.sendKeys('This is a paragraph tag');
這篇關(guān)于我如何在 e2e 測試 Angular Protractor 的標(biāo)簽中添加文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!