Reputation: 11
I am always getting this below exception while running my tests with Selenium Webdriver.
I have done some Googling but couldn't find anything related to this exception but found that this exception occurs when you are executing JavaScript in your code but I am NOT doing so.
Code throwing this exception:-
public void foo(){
WebDriver driver = new FirefoxDriver();
driver.get("www.xyz.com");
driver.switchTo().defaultContent();
driver.switchTo().frame(driver.findElement(By.xpath("(//iframe[contains(@id ,'easyXDM_default')])[2]")));
WebElement resultsDiv = driver.findElement(By.xpath("(//textarea[contains(@id,'ext-comp')])[1]"));
.....
}
Exception is thrown whenever we are finding the textarea field in the application & the field is inside the frame.
Below is the stack trace:-
org.openqa.selenium.WebDriverException: b is null
Command duration or timeout: 21 milliseconds Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39' System info: host: 'HPDA0128', ip: '10.9.60.36', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_55' Session ID: f228cc09-2dd5-4658-9950-c504bf007b7f 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=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=30.0}] at sun.reflect.GeneratedConstructorAccessor13.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:595) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:348) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:445
How can I resolve this error or what does this error signify/mean?
Upvotes: 1
Views: 2239
Reputation: 175
I had the same error while trying to click on an element of my webpage. I also tried to use coordinates but had the same error. (Javascript error b is null)
But it finally work by adding a refresh code line before trying to access and click to the element.
Before:
By myBy= By.xpath("//img[contains(@title,'title')]");
driver.findElement(myBy).click();
After:
driver.navigate().refresh();
By myBy= By.xpath("//img[contains(@title,'title')]");
driver.findElement(myBy).click();
Maybe you should try to refresh your page (driver.navigate().refresh();) before trying to access the element.
Upvotes: 0