Apache POI在Selenium中格式不正确的文本

因此,我仍在为作为学校实习生的公司开发此职位发布软件。 该软件从.docx文件中读取职位描述,然后使用Selenium将其打印到职位发布网站上的容器中。

这是我的类,用于读取.docx并将其写入容器:

public class Description extends Driver {

    public static final String CRETURN = "\r";

    public static void ReadWriteDocx() {

        try {
            File file = new File("C:\\Basics.docx");
            FileInputStream fis = new FileInputStream(file.getabsolutePath());
            XWPFDocument document = new XWPFDocument(fis);
            List<XWPFParagraph> paragraphs = document.getParagraphs();
            for (int i = 0; i < paragraphs.size(); i++) {
                if (paragraphs.get(i).getParagraphText() != "") {
                    getDriver().findElement(By.id("AppendedJobDescription-editor-content")).sendKeys(CRETURN);
                }
                getDriver().findElement(By.id("AppendedJobDescription-editor-content")).sendKeys(paragraphs.get(i).getParagraphText());
            }
            fis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
} 

粘贴后的说明如下:

IT推广(m / w / d)Du arbeitest gerne mit deinem电脑或笔记本电脑? Dann bist du bei uns genau richtig!更多信息,请访问IT支持者。 IhreTätigkeiten。 -PC的auf- / abbauen-IT传输-Kundensupport Ihre Qualifikationen。 -fließendesdeutsch-信息技术中的Grundkenntnisse-Erfahrungen mit Hard- und Software-microsoft Office中的Grundkenntnisse

This is what it should look like. 最重要的部分不是,标题是粗体还是蓝色,但是有项目符号和回车符。

我的方法完全错误吗? 如果有人可以给我一个建议,我将不胜感激。

tangshuo4444 回答:Apache POI在Selenium中格式不正确的文本

尝试将\n用作目标丰富输入中的换行符,而不是\r

本文链接:https://www.f2er.com/3143894.html

大家都在问