Thursday, March 7, 2013

WebDriver using TestNG annotations


If you are using the TestNG Annotation then no need to use the main() function . it is not supporting to main function. Simply use function :-

package hQF;

import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Refinance {

// Useing teh Annontation Test So used normal function
 @Test
 public static void Test() throws InterruptedException
// public static void main(String[] args) throws Exception {
final String var = "prog_bg";
WebDriver driver = new FirefoxDriver();
// WebDriver driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://hsh.com");
Thread.sleep(1000);
List<WebElement> DefualtRadio = driver.findElements(By
.xpath("//input[@value='REFI']"));
System.out.println("ByDefault Refinance radio is selected  "
+ DefualtRadio.get(0).getAttribute("checked"));
}
    else {
// Call the test method
      Test();
       }

No comments:

Post a Comment