{"action":"created","issue":{"url":"https://api.github.com/repos/chrsmith/selenium-test/issues/26","labels_url":"https://api.github.com/repos/chrsmith/selenium-test/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/selenium-test/issues/26/comments","events_url":"https://api.github.com/repos/chrsmith/selenium-test/issues/26/events","html_url":"https://github.com/chrsmith/selenium-test/issues/26","id":54257813,"number":26,"title":"Should block on AJAX calls","user":{"login":"chrsmith","id":4029847,"avatar_url":"https://avatars.githubusercontent.com/u/4029847?v=3","gravatar_id":"","url":"https://api.github.com/users/chrsmith","html_url":"https://github.com/chrsmith","followers_url":"https://api.github.com/users/chrsmith/followers","following_url":"https://api.github.com/users/chrsmith/following{/other_user}","gists_url":"https://api.github.com/users/chrsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/chrsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrsmith/subscriptions","organizations_url":"https://api.github.com/users/chrsmith/orgs","repos_url":"https://api.github.com/users/chrsmith/repos","events_url":"https://api.github.com/users/chrsmith/events{/privacy}","received_events_url":"https://api.github.com/users/chrsmith/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/selenium-test/labels/Component-WebDriver","name":"Component-WebDriver","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/selenium-test/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/selenium-test/labels/Type-Enhancement","name":"Type-Enhancement","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"chrsmith","id":4029847,"avatar_url":"https://avatars.githubusercontent.com/u/4029847?v=3","gravatar_id":"","url":"https://api.github.com/users/chrsmith","html_url":"https://github.com/chrsmith","followers_url":"https://api.github.com/users/chrsmith/followers","following_url":"https://api.github.com/users/chrsmith/following{/other_user}","gists_url":"https://api.github.com/users/chrsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/chrsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrsmith/subscriptions","organizations_url":"https://api.github.com/users/chrsmith/orgs","repos_url":"https://api.github.com/users/chrsmith/repos","events_url":"https://api.github.com/users/chrsmith/events{/privacy}","received_events_url":"https://api.github.com/users/chrsmith/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-01-13T22:29:50Z","updated_at":"2015-01-13T22:30:04Z","closed_at":null,"body":"Original [issue 26](https://code.google.com/p/selenium/issues/detail?id=26) created by chrsmith on 2007-09-30T14:48:49.000Z:\n\nWebDriver presents a blocking API for normal requests, but it should also block on AJAX requests \r\ntoo. "},"comment":{"url":"https://api.github.com/repos/chrsmith/selenium-test/issues/comments/69833813","html_url":"https://github.com/chrsmith/selenium-test/issues/26#issuecomment-69833813","issue_url":"https://api.github.com/repos/chrsmith/selenium-test/issues/26","id":69833813,"user":{"login":"chrsmith","id":4029847,"avatar_url":"https://avatars.githubusercontent.com/u/4029847?v=3","gravatar_id":"","url":"https://api.github.com/users/chrsmith","html_url":"https://github.com/chrsmith","followers_url":"https://api.github.com/users/chrsmith/followers","following_url":"https://api.github.com/users/chrsmith/following{/other_user}","gists_url":"https://api.github.com/users/chrsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/chrsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrsmith/subscriptions","organizations_url":"https://api.github.com/users/chrsmith/orgs","repos_url":"https://api.github.com/users/chrsmith/repos","events_url":"https://api.github.com/users/chrsmith/events{/privacy}","received_events_url":"https://api.github.com/users/chrsmith/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T22:30:04Z","updated_at":"2015-01-13T22:30:04Z","body":"Comment [#5](https://code.google.com/p/selenium/issues/detail?id=26#c5) originally posted by chrsmith on 2010-01-15T19:44:02.000Z:\n\nHi, I just would like to share some code in my apps that I have in a base class that\r\nall my page objects extends. Maybe this may be useful as workaround meanwhile this is\r\nimplemented in the core library. For me it has worked fine and it has timeouts.\r\n\r\npublic WebElement waitFindElement(By by, long timeout, long interval){\r\n\t\tlong start = System.currentTimeMillis();\r\n\t\twhile(true){\r\n\t\t\ttry{\r\n\t\t\t\treturn driver.findElement(by);\r\n\t\t\t}\r\n\t\t\tcatch(NoSuchElementException nse){\r\n\t\t\t\tif(System.currentTimeMillis()-start>=timeout){\r\n\t\t\t\t\tthrow new Error(\"Timeout reached and element[\"+by+\"]not found\");\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tsynchronized(this){\r\n\t\t\t\t\t\t\twait(interval);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tpublic List<WebElement> waitFindElements(By by, long timeout, long interval){\r\n\t\tlong start = System.currentTimeMillis();\r\n\t\twhile(true){\r\n\t\t\ttry{\r\n\t\t\t\treturn driver.findElements(by);\r\n\t\t\t}\r\n\t\t\tcatch(NoSuchElementException nse){\r\n\t\t\t\tif(System.currentTimeMillis()-start>=timeout){\r\n\t\t\t\t\tthrow new Error(\"Timeout reached and element[\"+by+\"]not found\");\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tsynchronized(this){\r\n\t\t\t\t\t\t\twait(interval);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tpublic List<WebElement> waitFindElementsIn(WebElement element, By by, long timeout,\r\nlong interval){\r\n\t\tlong start = System.currentTimeMillis();\r\n\t\tList<WebElement> elements = element.findElements(by);\r\n\t\twhile(elements.isEmpty()){\r\n\t\t\tif(System.currentTimeMillis()-start>=timeout){\r\n\t\t\t\treturn elements;\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\ttry {\r\n\t\t\t\t\tsynchronized(this){\r\n\t\t\t\t\t\twait(interval);\r\n\t\t\t\t\t}\r\n\t\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telements=element.findElements(by);\r\n\t\t}\r\n\t\treturn elements;\r\n\t}"}}