This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//make sure it's run after every page load | |
public static void injectSJTXE(WebDriver driver) throws IOException { | |
URL url; | |
String js; | |
url = Resources.getResource(ExtJSUtil.class, "SJTXE.js"); | |
js = Resources.toString(url, Charsets.UTF_8); | |
((JavascriptExecutor) driver).executeScript(js); | |
} | |
//code to check if there are ExtJS Ajax error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Client side utilities for Selenium tests of ExtJS web applications | |
//requires ExtJS and Underscore libraries | |
//SJTXE - Selenium JavaScript Testing eXtension for ExtJS | |
(function(root, Ext) { | |
var root = root || window; | |
var me = root; | |
var Ext = Ext; | |
//private vars | |
var hasJSError = false; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 of inputEl | |
//the only change here is the addition of inputEl before .id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//make sure it's run after every page load | |
public static void injectSJTXE(WebDriver driver) throws IOException { | |
URL url; | |
String js; | |
url = Resources.getResource(ExtJSUtil.class, "SJTXE.js"); | |
js = Resources.toString(url, Charsets.UTF_8); | |
((JavascriptExecutor) driver).executeScript(js); | |
} | |
//code to check if there are ExtJS Ajax error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Client side utilities for Selenium tests of ExtJS web applications | |
//requires ExtJS and Underscore libraries | |
//SJTXE - Selenium JavaScript Testing eXtension for ExtJS | |
(function(root, Ext) { | |
var root = root || window; | |
var me = root; | |
var Ext = Ext; | |
//private vars | |
var hasAjaxFailure = false; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this example assuming storeID is known | |
ArrayList<Object> storeData = (ArrayList<Object>) ((JavascriptExecutor) driver) | |
.executeScript("return _.pluck(Ext.StoreManager.get(storeID).getRange(), 'data');", storeID); | |
//get number of rows in the store's data | |
int numberOfRows = storeData.size(); | |
//get the first row, you are going to see a JSON string on Java console | |
System.out.println(storeData.get(0)); | |
//get the first row's value for the column "name" | |
String name = ((Map<String, Object>) storeData.get(0)).get("name").toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public waitForAjax(WebDriver driver, int timeOutInSeconds) { | |
(new WebDriverWait(driver, timeOutInSeconds)) | |
.until(new ExpectedCondition<Boolean>() { | |
public Boolean apply(WebDriver d) { | |
return (Boolean) ((JavascriptExecutor) d) | |
.executeScript("return !(ExtJSUtil.hasActiveAjaxCalls(Ext.Ajax.requests && !_.isEmpty(Ext.Ajax.requests));"); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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;"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Rule | |
public TakeScreenshotOnFailRule rule = new TakeScreenshotOnFailRule(driver, folderName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TakeScreenshotOnFailRule extends TestWatcher { | |
protected String _folder; | |
protected WebDriver _driver; | |
public TestRule(WebDriver driver, String folder) { | |
_folder = folder; | |
_driver = driver; | |
} | |
@Override | |
protected void failed(Throwable e, Description description) { |