So I have a selenium/Python script that reads a JSON file for a list of URL and then one by one browses them; and takes screenshot.
I want to generate a result report (HTML) at the end of test BUT with following;
The report should not just say that script passed/failed but it also shares the result against each parameter URL. For example if 2 out of 5 websites were down at the point of test then it is reflected in the HTML results. Like facebook.com - OK while www.sdadas.com - Failed
Here is my code:
with open('Path to JSON file', encoding='utf-8') as s:
data = json.loads(s.read())
driver = Edge()
driver.set_page_load_timeout(10)
driver.implicitly_wait(5)
for site in data['sites']:
driver.get(data['sites'][site])
driver.get_screenshot_as_file("Screenshot path\\Image" + site + '.png')
driver.close()
My JSON file
{
"sites": {
"facebook": "http://www.facebook.com",
"Wrong": "http://www.gonssgle.com"
}
}