I am attempting to determine if an element is visible in mobile Safari. When executing the following code in debug mode in Eclipse everything works fine but when I do a full run it fails with the error “Element does not exist in cache” on the .isDisplayed call.
Can’t determine why it’s failing or why it works fine in debug mode. I have attempted other methods of detecting the presence of the element (even though this one works as proven by the line that’s commented out) and I’ve also attempted to put arbitrary waits in various places with no success (not that it should matter because the first line should wait until the element exists before proceeding anyway).
WebElement element = (new WebDriverWait(wd, timeout)) .until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpath))); //element.getAttribute("innerHTML") returns the expected text so I know the element has been found and is present. boolean elementVisible;
elementVisible = element.isDisplayed();
Here is the relevant piece of the server log showing the error…
2016-06-06 16:27:45:490 - [HTTP] → GET /wd/hub/session/3bed1ab4-c4a9-4c71-b74a-3f5600c67330/element/5007/displayed {}
2016-06-06 16:27:45:492 - [MJSONWP] Calling AppiumDriver.elementDisplayed() with args: [“5007”,“3bed1ab4-c4a9-4c71-b74a-3f5600c67330”]
2016-06-06 16:27:45:494 - [debug] [iOS] Executing iOS command ‘elementDisplayed’
2016-06-06 16:27:45:495 - [debug] [RemoteDebugger] Executing ‘is_displayed’ atom in default context
2016-06-06 16:27:45:495 - [debug] [RemoteDebugger] Sending javascript command (function(){return function…
2016-06-06 16:27:45:496 - [debug] [RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to remote debugger
2016-06-06 16:27:45:513 - [debug] [RemoteDebugger] Received applicationSentData response
2016-06-06 16:27:45:513 - [debug] [RemoteDebugger] Found data handler for response
2016-06-06 16:27:45:513 - [debug] [RemoteDebugger] Received data response from socket send: ‘"{"status":10,"value":{…’
2016-06-06 16:27:45:514 - [debug] [RemoteDebugger] Original command: sendJSCommand
2016-06-06 16:27:45:515 - [debug] [iOS] Error received while executing atom: Element does not exist in cache (status: 10)