0

I am getting below exception when I am trying to do driver.findElements(By.xpath("//button/span[text()='Cancel']/../following-sibling::button/span[text()='Ok']")).size()!=0.

Though I am using driver.findElements at other places also, but its failing here.

Chrome: 58x version
ChromeDriver: 2.29 version
Selenium: 2.52 version

Error trace-back:

org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot find context with specified id"} (Session info: chrome=58.0.3029.110) (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 5.44 seconds Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16' System info: host: 'Iaglab2', ip: '', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_75' *** Element info: {Using=xpath, value=//button/span[text()='Cancel']/../following-sibling::button/span[text()='Ok']} Session ID: 44c20fabdca96942ee2f9de6fc7d3c23 Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=WIN8_1, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\hravi\AppData\Local\Temp\scoped_dir9172_8986, chromedriverVersion=2.29.461591 (62ebf098771772160f391d75e589dc567915b233)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=58.0.3029.110, pageLoadStrategy=normal, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true}]

3
  • Can you check whether element is inside frame or not ? Commented Jun 9, 2017 at 6:01
  • Yes, Element is inside frame but I am already on that frame and performing other actions before its getting failed here. And same code is working on other machine with same configuration Commented Jun 12, 2017 at 3:09
  • i'm getting the same exact issue, not consistently though. Commented Jul 13, 2017 at 17:34

3 Answers 3

1

Looks like it is a bug with Chrome driver.

Chrome driver bug -1224

But this bug was fixed for chrome driver v2.21. But we are again facing similar issue. I am facing same issue with 2.30 and even with latest 2.32 versions.

Sign up to request clarification or add additional context in comments.

1 Comment

The OP's error is NOT the problem that was fixed with Chromedriver bug 1224.
0

Alternatively, you could "ignore" this exception, so instead of except NoSuchElementException:, you could generalize all exceptions

def check_exists_by_xpath(xpath,driver):
try:
    driver.find_element_by_xpath(xpath)
except: #All exceptions are handeled here
    return False
return True

It worked for me

Comments

-1

go to.... File>Invalidate Caches>Invalidate Caches and Restart ...

1 Comment

where exactly ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.