I am dynamically generating a HTML file in Java Selenium Webdriver. The HTML file has two div tags with each having their own unique id attribute.
I want to dynamically add HTML text to these div tags based upon their id's at a later point in my code.
Can this be achieved? If yes, can someone point me in right direction in regards to how to achieve this? If no, what is an alternative way to achieve this?
I am struggling to tackle this scenario. I really need to be able to dynamically append the data to the HTML page based on div tags.
Thanks in advance!
public void createsummaryfile(String report,String path) throws IOException{
File summary;
summary = new File(filepath);
if(!summary.exists()){
summary.createNewFile();
}
BufferedWriter bw = new BufferedWriter(new FileWriter(summary));
bw.write("<!DOCTYPE html>");
bw.write("<html><head><h1 align=center>EDC Reports Test Case Execution Summary</h1>");
bw.write("<style>#report_table{height: 300px;left: 1em;position: relative;top: 5em;width: 300px;}#report{height: 300px;left: 20em;position: relative;top: -15em;width: 300px;}</style></head>");
bw.write("<body><div id=report_table><table align=center border=1><tbody><tr><th>Report Name</th></tr></div>");
bw.write("<body><div id=report_display></div>");
bw.write("</html>");
bw.close();
}
public void populate_summary(String report,String path) throws IOException{
File summary_report = new File(filepath);
BufferedWriter br = new BufferedWriter(new FileWriter(summary_report,true));
//Here I need to access the div tags by their id's and start appending data
}