trying to run a webdriver test for google chrome but unable to run it is giving some exceptions

package mypac;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.WebDriver;
public class Mytest {
    public static void main(String[] args) {
        String baseurl = "http://www.timecrunch.me";
        WebDriver driver = new FirefoxDriver();
        System.setProperty("webdriver.chrome.driver", "D:\\chromedriver_win32\\chromedriver.exe");
        WebDriver driver1 = new ChromeDriver();
        driver.get(baseurl);
        driver.findElement(By.name("wpusername")).sendKeys("ankitramola37");
        driver.findElement(By.name("wppassword")).
        sendKeys("ongrapha");
        driver.findElement(By.id("logoutBtn")).click();
    driver.findElement(By.id("fcNewEventTitle ")).click();
    driver.findElement(By.id("fcNewEventTitle ")).sendKeys("birthday ");
    driver1.get(baseurl);
    driver1.findElement(By.name("wpusername ")).sendKeys("ankitramola37 ");
    driver1.findElement(By.name("wppassword ")).sendKeys("ongrapha ");
    driver1.findElement(By.id("logoutBtn ")).click();
    driver1.findElement(By.id("fcNewEventTitle ")).click();
    driver1.findElement(By.id("fcNewEventTitle ")).sendKeys("birthday ");
    }
}   

tried this code but unable to run it

exception Starting ChromeDriver (v2.7.236900) on port 19245
Exception in thread "main " org.openqa.selenium.NoSuchElementException: Unable to locate 
element: {"
        method ":"
        id ","
        selector ":"
        fcNewEventTitle "}
Command duration or timeout: 12.47 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions
/no_such_element.html
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'Comp-PC', ip: '192.168.2.28', os.name: 'Windows 7', os.arch: 'x86',
 os.version: '6.1', java.version: '1.7.0_51'
Session ID: 5ff1488c-950a-47e2-8f80-a62bcc5766d7
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(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:220)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at mypac.Mytest.main(Mytest.java:25)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to 
locate element: {"
        method ":"
        id ","
        selector ":"
        fcNewEventTitle "}
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'Comp-PC', ip: '192.168.2.28', os.name: 'Windows 7', os.arch: 'x86', 
os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/User
s/Comp/AppData/Local/Temp/anonymous1178081315003174620webdriver-profile/extensions
/fxdriver@googlecode.com/components/driver_component.js:8860)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users
/Comp/AppData/Local/Temp/anonymous1178081315003174620webdriver-profile/extensions
/fxdriver@googlecode.com/components/driver_component.js:8869)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users
/Comp/AppData/Local/Temp/anonymous1178081315003174620webdriver-profile/extensions
/fxdriver@googlecode.com/components/command_processor.js:10831)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users
/Comp/AppData/Local/Temp/anonymous1178081315003174620webdriver-profile/extensions
/fxdriver@googlecode.com/components/command_processor.js:10836)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users
/Comp/AppData/Local/Temp/anonymous1178081315003174620webdriver-profile/
/fxdriver@googlecode.com/components/command_processor.js:107`enter code here`78)

Answers


The error is due to because the element which your trying to locate fcNewEventTitle is not present, which gives this error:

Unable to

locate element: {"method":"id","selector":"fcNewEventTitle"}
. . . . 

Before you do something like this:

driver1.findElement(By.id("fcNewEventTitle")).click();

wait for that element. See here for more details.


Need Your Help

wrap 32 bit dll for 64 bit operating system to work with regsvr32.exe

c# asp-classic dllregistration

We are currently transferring our websites from Windows 2003 (32-bit) to Windows 2008 (64-bit) and have hit a problem.

Lucene's nested query evaluation regarding negation

java lucene type-safety querydsl

I am adding Apache Lucene support to Querydsl (which offers type-safe queries for Java) and I am having problems understanding how Lucene evaluates queries especially regarding negation in nested q...