I am new to Selenium
and I have written following code to print alert text and accept alert.
public class AlertPractice {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://output.jsbin.com/usidix/1");
driver.findElement(By.cssSelector("input[value=\"Go!\"]")).click();
Thread.sleep(1000);
String S = driver.switchTo().alert().getText();
Thread.sleep(1000);
driver.switchTo().alert().accept();
System.out.println(S);
driver.close();
}
On running with FIREFOX driver I get following exception :
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output....
and on Running with Chrome Driver I get below exceptions:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status from unexpected alert open (Session info: chrome=53.0.2785.101) (Driver info: chromedriver=2.21.371459 ...
Any help would be appreciable.