diff --git a/.classpath b/.classpath index 74de241..2e08392 100644 --- a/.classpath +++ b/.classpath @@ -21,6 +21,38 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index b83d222..6f6ea3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target/ +/.apt_generated/ +/.apt_generated_tests/ diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index d2ac26b..708ed72 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -7,5 +7,6 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.processAnnotations=enabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index 7dcb803..b7923fe 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,13 @@ 1.18.12 provided - + + + org.testng + testng + 7.3.0 + test + diff --git a/src/main/java/pres/auxiliary/tool/file/AbstractWriteFile.java b/src/main/java/pres/auxiliary/tool/file/AbstractWriteFile.java new file mode 100644 index 0000000..6886a8e --- /dev/null +++ b/src/main/java/pres/auxiliary/tool/file/AbstractWriteFile.java @@ -0,0 +1,55 @@ +package pres.auxiliary.tool.file; + +import java.util.HashMap; + +import pres.auxiliary.tool.file.excel.ReplactFunction; + +public abstract class AbstractWriteFile { + /** + * 用于对待替换词语的标记 + */ + protected final String WORD_SIGN = "\\#"; + + /** + * 用于存储待替换的词语以及被替换的词语 + */ + protected HashMap replaceWordMap = new HashMap<>(16); + + /** + * 用于设置需要被替换的词语。添加词语时无需添加特殊字符 + * + * @param word 需要替换的词语 + * @param replactWord 被替换的词语 + */ + public void setReplactWord(String word, String replactWord) { + setReplactWord(word, (text) -> { + return replactWord; + }); + } + + /** + * 用于根据需要替换的词语,设置需要动态写入到文本的内容。添加词语时无需添加特殊字符 + * @param word 需要替换的词语 + * @param replactFunction 替换规则 + */ + public void setReplactWord(String word, ReplactFunction replactFunction) { + replaceWordMap.put(word, replactFunction); + } + + /** + * 用于对需要进行替换的特殊词语进行替换 + * @param contents 文本内容 + */ + protected String[] replaceWord(String[] contents) { + // 查找特殊词语,并对词语进行替换 + for (String word : replaceWordMap.keySet()) { + // 查找所有的0内容,并将特殊词语进行替换 + for (int i = 0; i < contents.length; i++) { + String regex = WORD_SIGN + word + WORD_SIGN; + contents[i] = contents[i].replaceAll(regex, replaceWordMap.get(word).replact(word)); + } + } + + return contents; + } +} diff --git a/src/main/java/pres/auxiliary/tool/file/excel/AbstractWriteExcel.java b/src/main/java/pres/auxiliary/tool/file/excel/AbstractWriteExcel.java index 3d64738..9e4e670 100644 --- a/src/main/java/pres/auxiliary/tool/file/excel/AbstractWriteExcel.java +++ b/src/main/java/pres/auxiliary/tool/file/excel/AbstractWriteExcel.java @@ -227,7 +227,7 @@ public abstract class AbstractWriteExcel> { * @param replactWord 被替换的词语 */ public void setReplactWord(String word, String replactWord) { - setReplactWord(word, (text) -> { + setReplactWord(word, (text) -> { return replactWord; }); } diff --git a/src/main/java/pres/auxiliary/work/selenium/event/JsEvent.java b/src/main/java/pres/auxiliary/work/selenium/event/JsEvent.java index 253f69b..78fc9d0 100644 --- a/src/main/java/pres/auxiliary/work/selenium/event/JsEvent.java +++ b/src/main/java/pres/auxiliary/work/selenium/event/JsEvent.java @@ -205,7 +205,13 @@ public class JsEvent extends AbstractEvent { // 执行代码,由于在获取元素信息时已经对元素的过期进行了判断,故此处无需在做判断 js.executeScript(script, element.getWebElement()); - + + /* + var a = document.getElementById('psd') + var aa = a.parentNode + aa.removeChild(a) + * + * */ return json; } diff --git a/src/main/java/pres/auxiliary/work/selenium/xml/ElementData.java b/src/main/java/pres/auxiliary/work/selenium/xml/ElementData.java new file mode 100644 index 0000000..e164b07 --- /dev/null +++ b/src/main/java/pres/auxiliary/work/selenium/xml/ElementData.java @@ -0,0 +1,16 @@ +package pres.auxiliary.work.selenium.xml; + +/** + *

文件名:ElementData.java

+ *

用途: + * 用于存储页面元素的基本信息,以便于在查找中进行使用 + *

+ *

编码时间:2020年9月27日上午7:50:44

+ *

修改时间:2020年9月27日上午7:50:44

+ * @author 彭宇琦 + * @version Ver1.0 + * + */ +public class ElementData { + +} diff --git a/src/test/java/pres/auxiliary/testcase/writecase/TestAddInformation.java b/src/test/java/pres/auxiliary/testcase/writecase/TestAddInformation.java index 550b1e9..416ee24 100644 --- a/src/test/java/pres/auxiliary/testcase/writecase/TestAddInformation.java +++ b/src/test/java/pres/auxiliary/testcase/writecase/TestAddInformation.java @@ -3,9 +3,9 @@ package pres.auxiliary.testcase.writecase; import java.io.File; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import pres.auxiliary.work.old.testcase.change.Tab; import pres.auxiliary.work.old.testcase.templet.ZentaoTemplet; @@ -20,7 +20,7 @@ public class TestAddInformation { static AddInformation a; @BeforeClass - public static void createTemplet() throws Exception { + public void createTemplet() throws Exception { ZentaoTemplet.setCoverFile(true); ZentaoTemplet.create(); diff --git a/src/test/java/pres/auxiliary/work/testcase/file/JiraTestCaseWriteTest.java b/src/test/java/pres/auxiliary/work/testcase/file/JiraTestCaseWriteTest.java index b70eb2a..2de2977 100644 --- a/src/test/java/pres/auxiliary/work/testcase/file/JiraTestCaseWriteTest.java +++ b/src/test/java/pres/auxiliary/work/testcase/file/JiraTestCaseWriteTest.java @@ -63,6 +63,7 @@ public class JiraTestCaseWriteTest { @BeforeMethod public void addContent(Method method) { System.out.println("=======正在运行:" + method.getName() + "======="); + wtc.switchSheet("测试用例"); } /** @@ -155,27 +156,4 @@ public class JiraTestCaseWriteTest { dlc.setReplaceWord(DataListCase.DATA_NAME, "用户"); wtc.addCase(dlc.appBrowseListCase()); } - - /** - * 综合测试 - */ - @Test - public void synthesizeTest() { - wtc.addTitle("测试一个标题") - .addModule("企业", "标段现场") - .addStep("步骤1", "步骤2") - .addExcept("预期1", "预期2") - .addStepAndExcept("步骤3", "预期3") - .addContent(JiraFieldIdType.CASE_KEY.getName(), "1") - .addContent(JiraFieldIdType.COMPONENT.getName(), "4") - .addContent(JiraFieldIdType.ISSUES.getName(), "4") - .addContent(JiraFieldIdType.OBJECTIVE.getName(), "目的") - .addContent(JiraFieldIdType.OWNER.getName(), "彭宇琦") - .addContent(JiraFieldIdType.PRECONDITION.getName(), "前置1", "前置2") - .addContent(JiraFieldIdType.PRIORITY.getName(), "1") - .addContent(JiraFieldIdType.STATUS.getName(), "3") - .end() - .changeTextColor(JiraFieldIdType.STEP.getName(), 0, MarkColorsType.GREEN) - .fieldComment(JiraFieldIdType.FOLDER.getName(), "模块标记"); - } } diff --git a/src/test/java/pres/auxiliary/work/testcase/用例xml文件.xml b/src/test/java/pres/auxiliary/work/testcase/用例xml文件.xml index e73d681..d9b94db 100644 --- a/src/test/java/pres/auxiliary/work/testcase/用例xml文件.xml +++ b/src/test/java/pres/auxiliary/work/testcase/用例xml文件.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/test/java/test/javase/Test123.java b/src/test/java/test/javase/Test123.java index 1446ed7..1fe7551 100644 --- a/src/test/java/test/javase/Test123.java +++ b/src/test/java/test/javase/Test123.java @@ -9,6 +9,6 @@ public class Test123 { System.out.println(ss.split("\\.").length); System.out.println("The End"); - //System.out.println(UUID.randomUUID().toString()); + //System.out.pri ntln(UUID.randomUUID().toString()); } }