Skip to content

Instantly share code, notes, and snippets.

@huguogang
Created September 27, 2013 01:48
Show Gist options
  • Save huguogang/6723159 to your computer and use it in GitHub Desktop.
Save huguogang/6723159 to your computer and use it in GitHub Desktop.
Finding ExtJS component for Selenium WebDriver
//find the fully qualified component query of ExtJS component cmp
String query = cmp.componentQuery;
Component parent = cmp.parent;
while (parent != null) {
query = parent.componentQuery + " " + query;
parent = parent.parent;
}
//use component query to find id
String js = "return Ext.ComponentQuery.query(\"" + query + "\")[0].id;";
String id = (String) ((JavascriptExecutor) _driver).executeScript(js);
WebElement element = driver.findElement(By.id(id));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment