How to read sites url from Json file and open URLs into browser
To read sites url from Json file and open URLs into browser, Here are the steps to achieve this:
1) Add checkList.json
to your application .
2) Add many sites with name Like
{
"CheckListScenario": [
{
"URL": "http://www.google.com",
"Key": "google"
},
{
"URL": "http://facebook.com",
"Key": "facebook"
}
]
}
3) Read data from Json
string jsonString = System.IO.File.ReadAllText(jsonPath);
4) DeserializeObject from Json to mapping Classes
CheckListScenarioTest checklist = JsonConvert.DeserializeObject<CheckListScenarioTest>(jsonString);
5) Adding URL into List and Open site automatically in browser
foreach (var item in checklist.CheckListScenario)
{
ListOfSites.Add(item.URL);
Process.Start(item.URL);
}