5

Firefox14でJavaのWebdriverを使用しています。

私の問題は、WebdriverをCkEditorでうまく動作させることができないように見えることです。私は解決策を探しましたが、Firefox13または14のいずれかで動作させることができませんでした。これらは私が試した解決策です。

  1. 通常のsendKeysインタークション

    textArea.sendKeys();
    

    また

    textArea.click();
    textArea.sendKeys();
    

    結果:このコードはCkEditorにテキストを生成しません

  2. SeleniumIssue3890のコード

    d.get("http://ckeditor.com/demo");
    WebElement iframe = d.findElement(By.tagName("iframe"));
    d.switchTo().frame(iframe);
    WebElement tinymce = d.findElement(By.tagName("body"));
    tinymce.clear();
    tinymce.sendKeys("Hello, ckeditor!");
    

    結果:このコードはサイトに移動してエディターをクリアしますが、CkEditorインスタンスにテキストを入力しません。

  3. AdvancedUserInteractions-例:複数のバリエーションのActions()

    textArea.click();
    new Actions(driver).sendKeys("Hello, ckeditor!").build().perform();
    

    new Actions(driver).sendKeys(textArea, "Hello, ckeditor!").build().perform();
    

    new Actions(driver).click(textArea).sendKeys("Hello, ckeditor!").build().perform();
    

    結果:これらはCkEditorにテキストを生成しません

  4. iframeの切り替え(上記のIssue 3890による)とAdvancedUserInteractionsの使用

    次のようなコード:

    driver.switchTo().frame(iframe);
    textArea.click();
    new Actions(driver).sendKeys("Hello, ckeditor!").build().perform();
    

    結果:エラー「c.valueisundefined」をスローします

  5. JavascriptとCkEditorApiの使用

    JavascriptExecutor js = (JavascriptExecutor) d;
    System.out.println("[debug] Set Text: " + setText);
    js.executeScript("CKEDITOR.instances.editor1.setData('<p> "+ setText +"</p>');");
    

    結果:「 org.apache.commons.lang.StringEscapeUtils.escapeHtml 」が「 setText」をHtmlエントリに変換するために使用される/使用されない場合、「/」文字を除外します。このソリューションでは、大きな文字列に対して「 ERROR:null 」もスローされます。

私が試したことのないことについて何かアイデアはありますか?私が試したことの修正?他に何か提案はありますか?

ありがとう!

4

3 に答える 3

3

テキスト領域がIframeとして処理される場合があります。この場合、そのフレームに切り替えてJSコマンドを実行して入力する必要があります。

final WebDriver frame = driver.switchTo().frame(findElement(By.id("locator")); //any locator
    ((JavascriptExecutor) driver).executeScript("document.body.innerHTML='" + TestValueThatYouWantToType + "'");
    driver.switchTo().defaultContent();
于 2012-08-27T15:45:43.210 に答える
0

後にwaitステートメントを追加するだけで、tinymce.clear();正常に機能します。

于 2012-10-01T06:00:06.767 に答える
0

この問題に直面している人は、次のURLを参照できます。

http://bharath-marrivada.blogspot.com/2012/03/fckeditor-switch-activeelement.html

これを参照して私の問題を修正しました;D

于 2013-07-05T03:19:17.700 に答える