Showing posts with label automating the w3c css test with selenium. Show all posts
Showing posts with label automating the w3c css test with selenium. Show all posts

Thursday, January 6, 2011

automating the w3c css test with selenium

1.Create a table where url/body of css file is stored
2.Then fetch data from query
3.In a for loop send call to W3CCSSTest(selenium,dr)


public void W3CCSSTest(ISelenium selenium, DataRow dr)
{
string sql = "";
string cols = "";
string nexturl="";
verificationErrors = new StringBuilder("");

selenium.Open("/");


Thread.Sleep(2000);
try
{

if (dr["type"].ToString() == "U") // if url
{

selenium.Open("http://jigsaw.w3.org/css-validator/");
selenium.Type("uri", dr["BodyUrl"].ToString());
selenium.Click("link=More Options");
Thread.Sleep(1000);
selenium.Select("profile_uri", "label=No special profile");
selenium.Click("//fieldset[@id='validate-by-uri']/form/p[3]/label/a/span");
nexturl = "http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fjigsaw.w3.org%2Fcss-validator%2F&profile=none&usermedium=all&warning=1&lang=en";
}
if (dr["type"].ToString() == "B") //if body
{
selenium.Open("http://jigsaw.w3.org/css-validator/");
selenium.Click("link=By direct input");
selenium.Type("text", dr["BodyUrl"].ToString());
Thread.Sleep(1000);
selenium.Select("profile_input", "label=No special profile");
selenium.Click("//fieldset[@id='validate-by-input']/form/p[3]/label/a/span");
nexturl = "http://validator.w3.org/check?uri=http%3A%2F%2Fvalidator.w3.org%2F&charset=%28detect+automatically%29&doctype=HTML+4.01+Transitional&group=0&ss=1&No200=1";
}
Thread.Sleep(3000);

if (selenium.IsTextPresent("Congratulations!"))
{
verificationErrors.Append("pass,");
CreatedScreenShot = Utilities.SeleniumScreenShot(selenium, ScriptAndDirName, dr["Rid"].ToString() + "W3C_CSS_PASS");
DatabaseClass.LogDataInResultTable(ScriptAndDirName, TableName, Convert.ToInt16(dr["Rid"].ToString()), "P", CreatedScreenShot, Convert.ToString(verificationErrors), dr["owner"].ToString());
}

if (selenium.IsTextPresent("Sorry! We found the following errors"))
{
verificationErrors.Append("fail,");
CreatedScreenShot = Utilities.SeleniumScreenShot(selenium, ScriptAndDirName, dr["Rid"].ToString() + "W3C_CSS_FAIL");
DatabaseClass.LogDataInResultTable(ScriptAndDirName, TableName, Convert.ToInt16(dr["Rid"].ToString()), "F", CreatedScreenShot, Convert.ToString(verificationErrors), dr["owner"].ToString());
}
Thread.Sleep(3000);
selenium.GoBack();
}
catch (Exception ex)
{
verificationErrors.Append(ex.ToString());
selenium.GoBack();
}
}