Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java selenium webdriver如何获取在iframe wysiwyg文本区域中输入的文本_Java_Selenium_Iframe_Selenium Webdriver_Wysiwyg - Fatal编程技术网

Java selenium webdriver如何获取在iframe wysiwyg文本区域中输入的文本

Java selenium webdriver如何获取在iframe wysiwyg文本区域中输入的文本,java,selenium,iframe,selenium-webdriver,wysiwyg,Java,Selenium,Iframe,Selenium Webdriver,Wysiwyg,如何获取在iframe wysiwyg文本区域中输入的文本 // Enter text for Message field ContactUs_Page.txt_keyInMessage().sendKeys(ColMessage); ContactUs_Page.java public static WebElement txt_keyInMessage() throws Exception{ try{ WebElement iframeMsg= drive

如何获取在iframe wysiwyg文本区域中输入的文本

// Enter text for Message field
ContactUs_Page.txt_keyInMessage().sendKeys(ColMessage);
ContactUs_Page.java

public static WebElement txt_keyInMessage() throws Exception{
    try{     
        WebElement iframeMsg= driver.findElement(By.xpath("//*[contains(@class, 'wysiwyg_frame')]"));        
        driver.switchTo().frame(iframeMsg);     
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);         
        element = driver.findElement(By.cssSelector("body"));    
    }catch (Exception e){
        throw(e);
    }
    return element;
}
iframe html代码

<iframe class="wysiwyg_frame" frameborder="0" src="" style="width: 100%; height: 100%;" title="Rich Text Editor, contact_remarks" aria-describedby="cke_30" tabindex="0" allowtransparency="true">
    <!DOCTYPE html>
    <html lang="en" dir="ltr">
        <head>
        <body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="false">
            <p>
                hello, pls contact me once you received this message
                <br>
            </p>
        </body>
        </html>
</iframe>


您好,收到此消息后请与我联系

这里输入的文本是

“你好,收到此消息后请与我联系”

如果在普通文本框中,它可以使用
getAttribute(“值”)

但在iframe wysiwyg文本区域中,它没有
类型


请提供建议,谢谢。

看起来它只是
iframe
主体
元素的
文本

WebElement iframeMsg = driver.findElement(By.xpath("//*[contains(@class, 'wysiwyg_frame')]"));        
driver.switchTo().frame(iframeMsg);

WebElement body = driver.findElement(By.cssSelector("body"));
System.out.println(body.getText());