Tuesday, November 15, 2011

verifyTextPresent in Web Driver

Following function takes the WebElement and searches the text of elements with particular tags
public boolean verifyTextPresent(WebElement rootElement, String tag, String text) {
List elements = rootElement.findElements(By.tagName(tag));
boolean match = false;
for (WebElement elem : elements){
String elementText = elem.getText();
if (elementText.contains(text)){
match = true;
break;
}
}
try {
Assert.assertTrue(match);
System.out.println("\"" + text + "\" was found within elements within the passed in WebElement with ID (" + rootElement.getAttribute("id")+ ")");
}
catch (Exception e) {
System.err.println("\"" + text + "\" not found within elements within the passed in WebElement with ID (" + rootElement.getAttribute("id")+ ")");
}
return match;
}

Wednesday, November 2, 2011

Creating a Sitemap in Asp.Net

Create a New website first then right click on the project folder as shown in figure below.



Click on Add New Item, then you will see a dialogue box titled as 'Add New Item' and you see couple of installed templates as shown in below figure. In that templates if you scroll down you will see Site Map template. Select Site Map template and click on 'Add' button.


After adding SiteMap into your solution. It will generate default code as shown below. and it will be seen in your solution as shown in below figure.



<< Example on Sitemap Control in ASP.Net