Open browser and Check for element
import javax.swing.JOptionPane;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Sample1
{
public static void main(String[] args) throws InterruptedException
{
//WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("path/to/your/firefox.exe")), profile);
System.setProperty("webdriver.firefox.bin","E://Work//Program_files//Firefox17.0//firefox.exe");
FirefoxDriver oDriver=new FirefoxDriver();
oDriver.get("http://yahoo.com");
//oDriver.
try
{
WebElement oflag=oDriver.findElementByXPath("//*[@id='default-u_14119506-bd']/div/h1/span") ;
System.out.println("passed");
}catch(org.openqa.selenium.NoSuchElementException Ex)
{
System.out.println("failed");
}
JOptionPane.showMessageDialog(null,"Done");
//driver.findElement(By.id("...")).isDisplayed()
// String a=JOptionPane.showInputDialog(null,"What is your name ?");
// JOptionPane.showMessageDialog(null, a);
Thread.sleep(5000);
oDriver.close();
oDriver.quit();
}
}
No comments:
Post a Comment