static WebDriver driver = new FirefoxDriver();
public static void main(String[] args) throws IOException, InterruptedException {
// TODO code application logic here
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter base url....!!!");
String baseurl = br.readLine();
connection c= new connection();
c.makeConnection(driver,baseurl);
JavascriptExecutor js;
if (driver instanceof JavascriptExecutor) {
js = (JavascriptExecutor)driver;
js.executeScript("alert('hello world');");
}
An error message is displayed as follows:
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present: hello world
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Session ID: f6ba3a2b-87d4-4192-ad1a-94cf260d8f6e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:174)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:332)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:408)
at org.openqa.selenium.By$ByXPath.findElements(By.java:358)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:295)
at javaapplication4.count.linkCount(count.java:27)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:34)