Hi...
In my test class I am using selenium webdriver + testng + page Objects + IE browser
Now there is mandatory field check. on Clicking the "Next" button. a pop up message is shown "Lastname is mandatory." with button "ok". I have made two test classes say "home" and "HomeTest"
HomeTest.java containspublic class HomeTest {
private WebDriver driver;
@BeforeClass
public void initWebDriver() {
driver= new InternetExplorerDriver();
}
@Test
public void testGetErrorMesssage() throws Exception{
Home home=new Home(driver);
home.getErrorMessage();
}
Home.java contains@FindBy(name="button")
private RenderedWebElement next_button;
public Home(WebDriver driver) {
driver.get("
http://application.com");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 15), this);
}
public void getErrorMessage()throws Exception{
next_button.click();
Alert alert=driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();
}
But my problem is that Eclipse is showing an error line on "alert()" on line "Alert alert=driver.switchTo().alert();" in Home.java
when I mouse over and red line it is showing "The method alert() is undefined for the type WebDriver.TargetLocator"
I don't understand why is this happening :( ...and this is working fine when I am not using TestNG
Thanks