これはおそらく単純なことだと思いますが、間違ったことを見つけることができないようです。
Web ページからの出力をテキスト ファイルの内容と比較しています。次のコードがあり、Web ページからのすべての結果に対して、bufferedreader が 1 回ループするようです。コードと結果を投稿すると、混乱が少なくなります。
コード
String docOne = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div/div/h5")).getAttribute("textContent").toString();
String docTwo = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[2]/div/h5")).getAttribute("textContent").toString();
String docThree = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[3]/div/h5")).getAttribute("textContent").toString();
String docFour = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[4]/div/h5")).getAttribute("textContent").toString();
String docFive = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[5]/div/h5")).getAttribute("textContent").toString();
String docSix = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[6]/div/h5")).getAttribute("textContent").toString();
String docSeven = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[7]/div/h5")).getAttribute("textContent").toString();
String docEight = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div/div/div[2]/div/div[8]/div/h5")).getAttribute("textContent").toString();
String docNine = driver.findElement(By.xpath("/html/body/div[2]/div/div[2]/div/div[4]/div[2]/div/div/div[2]/div/div[2]/div/div/div/h5")).getAttribute("textContent").toString();
try (BufferedReader br = new BufferedReader(new FileReader("/Users/vhaislsalisc/Documents/CDWProductionDomainsRequiredDocs.txt"))) {
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
System.out.println("Webpage: " + docOne + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docTwo + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docThree + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docFour + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docFive + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docSix + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docSeven + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docEight + " Required Doc: " + sCurrentLine);
System.out.println("Webpage: " + docNine + " Required Doc: " + sCurrentLine);
}
br.close();
} catch (IOException e) {
System.err.println("Error: " + e.getMessage());
}
結果
Webpage: Research Request Memo (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Research Study Institutional Review Board (IRB) Approval Letter (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Sample Informed Consent and HIPAA Authorization (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Research and Development (RD) Committee Approval Letter (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Data Use Agreement (File Document) Required Doc: Research Request Memo (File Document)
Webpage: IRB Approval of Waiver of HIPAA-Compliant Authorization (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Research Protocol (File Document) Required Doc: Research Request Memo (File Document)
Webpage: CDW-Domain Checklist (File Document) Required Doc: Research Request Memo (File Document)
Webpage: VA Form 9957 (File Document) Required Doc: Research Request Memo (File Document)
Webpage: Research Request Memo (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: Research Study Institutional Review Board (IRB) Approval Letter (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: Sample Informed Consent and HIPAA Authorization (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: Research and Development (RD) Committee Approval Letter (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: Data Use Agreement (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: IRB Approval of Waiver of HIPAA-Compliant Authorization (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: Research Protocol (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: CDW-Domain Checklist (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
Webpage: VA Form 9957 (File Document) Required Doc: Research Study Institutional Review Board (IRB) Approval Letter (File Document)
など、ファイルの残りの部分まで
それで、私が何をしたのか、そしてファイルを1回だけ通過し、すべてがWebページからのものと一致するように修正するにはどうすればよいのでしょうか?