{"action":"created","issue":{"url":"https://api.github.com/repos/appium/appium/issues/6157","repository_url":"https://api.github.com/repos/appium/appium","labels_url":"https://api.github.com/repos/appium/appium/issues/6157/labels{/name}","comments_url":"https://api.github.com/repos/appium/appium/issues/6157/comments","events_url":"https://api.github.com/repos/appium/appium/issues/6157/events","html_url":"https://github.com/appium/appium/issues/6157","id":134494297,"number":6157,"title":"Unable to execute Isdisplayed() method","user":{"login":"areebashuja","id":12908019,"avatar_url":"https://avatars.githubusercontent.com/u/12908019?v=3","gravatar_id":"","url":"https://api.github.com/users/areebashuja","html_url":"https://github.com/areebashuja","followers_url":"https://api.github.com/users/areebashuja/followers","following_url":"https://api.github.com/users/areebashuja/following{/other_user}","gists_url":"https://api.github.com/users/areebashuja/gists{/gist_id}","starred_url":"https://api.github.com/users/areebashuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/areebashuja/subscriptions","organizations_url":"https://api.github.com/users/areebashuja/orgs","repos_url":"https://api.github.com/users/areebashuja/repos","events_url":"https://api.github.com/users/areebashuja/events{/privacy}","received_events_url":"https://api.github.com/users/areebashuja/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/appium/appium/labels/NeedsTriage","name":"NeedsTriage","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-18T06:37:26Z","updated_at":"2016-02-18T20:12:09Z","closed_at":null,"body":"Hi,\r\nI am stuck at a very important part of my automation which i am unable to resolve.\r\n\r\nI wanted to execute below code which indicates that:\r\n\r\n//if modal is displayed\r\nif(driver.findElement(By.xpath(\"//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]\")).isDisplayed())\r\n{\r\n//click yes\r\ndriver.findElement(By.xpath(\"//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]/android.widget.Button[1]\")).click();\r\n}\r\nelse\r\n{\r\n//else click back\r\ndriver.findElement(By.xpath(\"//android.view.View[1]/android.widget.LinearLayout[1]/android.view.View[1]/android.widget.ImageButton[1]\")).click();\t\r\n}\r\n\r\nThe problem is that, Appium is not identifying/considering isDisplayed() method, stucks on \"if\" clause and starts searching for the modal and the time out occurs and it doesn't go to next step at all.\r\n\r\nI have also tried to use below \"size\" method instead of \"isDisplayed\", but eclipse not accepting \"size\" method.\r\nif(driver.findElement(By.xpath(\"//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.FrameLayout[1]//android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]\")).size()>0)\r\n\r\n**Environment:**\r\n* Appium version: 1.4.16 \r\n* Eclipse version: eclipse_Kelper64 \r\n\r\nPlease suggest.\r\nThanks in advance\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/appium/appium/issues/comments/185895603","html_url":"https://github.com/appium/appium/issues/6157#issuecomment-185895603","issue_url":"https://api.github.com/repos/appium/appium/issues/6157","id":185895603,"user":{"login":"kcinman11358","id":7409848,"avatar_url":"https://avatars.githubusercontent.com/u/7409848?v=3","gravatar_id":"","url":"https://api.github.com/users/kcinman11358","html_url":"https://github.com/kcinman11358","followers_url":"https://api.github.com/users/kcinman11358/followers","following_url":"https://api.github.com/users/kcinman11358/following{/other_user}","gists_url":"https://api.github.com/users/kcinman11358/gists{/gist_id}","starred_url":"https://api.github.com/users/kcinman11358/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcinman11358/subscriptions","organizations_url":"https://api.github.com/users/kcinman11358/orgs","repos_url":"https://api.github.com/users/kcinman11358/repos","events_url":"https://api.github.com/users/kcinman11358/events{/privacy}","received_events_url":"https://api.github.com/users/kcinman11358/received_events","type":"User","site_admin":false},"created_at":"2016-02-18T20:12:09Z","updated_at":"2016-02-18T20:12:09Z","body":"Looks like your dev beat me to it, but yes waiting is your bet. Sometimes, it can just be that half a second that could cause your test to fail. Something that we have implemented is having a wait.until for each time we are looking for an element. This is in c#, but it should translate\r\n\r\npublic IWebElement GetElement(By by)\r\n        {\r\n            WebDriverWait wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 90));\r\n            wait.Until(ExpectedConditions.ElementToBeClickable(by));\r\n            return _driver.FindElement(by);\r\n        }"}}