Skip to content

Instantly share code, notes, and snippets.

View DanielGallo's full-sized avatar

Daniel Gallo DanielGallo

View GitHub Profile
@DanielGallo
DanielGallo / SplitButton.js
Last active November 17, 2017 18:49
Example Sencha Test suite for an Ext JS Split Button
describe('Split Button', function() {
// Run this test suite against the following Kitchen Sink example:
// http://examples.sencha.com/extjs/6.5.1/examples/kitchensink/?classic#toolbar-menus
it('Should find the Split Button', function() {
ST.button('splitbutton[text=Split Button]')
.visible();
});
it('Should click the button part of the Split Button', function() {
@DanielGallo
DanielGallo / RightClick.js
Created November 22, 2017 20:02
Example Sencha Test suite showing how to perform right-click actions in an Ext JS app
// This example demonstrates two methods of how to perform right-click actions on elements.
// Run this test suite against the following Ext JS example:
// http://examples.sencha.com/extjs/6.5.1/examples/classic/desktop/index.html
describe('Right Click', function() {
it('Should right-click on icon and show menu - Example 1', function() {
var driver = ST.defaultContext.driver;
// Pass in a locator (not a Ext Component Query, as WebDriver.io doesn't recognize them directly)
driver.rightClick('//span[text()="SystemStatus"]');
@DanielGallo
DanielGallo / ModernSplitButton.js
Created December 18, 2017 22:48
Example Sencha Test suite for an Ext JS Modern SplitButton
describe('Split Buttons', function() {
it('Should find a particular Split Button', function() {
// Find the particular line of buttons we're interested in, by looking for the text "Raised".
// Then go up to the first parent Component.
// Then find a Split Button within that line, with the text "SMALL".
ST.button('[html=Raised] ^ component:first splitbutton[text=SMALL]')
.visible();
});
it('Should click on Menu button inside of Split Button', function() {
@DanielGallo
DanielGallo / Application.js
Created March 21, 2018 22:20
Ext JS - AMF Store example
/**
* The main application class. An instance of this class is created by app.js when it
* calls Ext.application(). This is the ideal place to handle application launch and
* initialization details.
*/
Ext.define('MyApp.Application', {
extend: 'Ext.app.Application',
requires: [
'Ext.direct.AmfRemotingProvider'
@DanielGallo
DanielGallo / Spreadsheet.js
Created April 10, 2018 04:38
Using Node.js modules in Sencha Test WebDriver test suites
/*
Author: Dan Gallo
Date: June 2017
Test URL: http://examples.sencha.com/ExtReact/6.5.0/kitchensink/#/grids/core_features/basic_grid
Purpose: This test suite for a WebDriver scenario can be used for demonstrating data-driven
testing capabilities. The test loops through the Excel file's worksheet and ensures
that data in the grid matches the Excel sheet.
@DanielGallo
DanielGallo / ErrorThrowing.js
Created April 10, 2018 22:48
Jasmine - Throwing errors
describe('Throwing errors', function() {
var user = {
getUser: function(id) {
// Do something
}
};
it('Should throw a custom error message', function() {
spyOn(user, 'getUser').and.throwError('No user ID specified');
@DanielGallo
DanielGallo / FileUpload.js
Last active June 15, 2021 06:57
File upload from Sencha Test WebDriver Scenario
// Scenario URL: http://examples.sencha.com/extjs/6.6.0/examples/kitchensink/?classic#form-fileuploads
describe('File Upload', function() {
it('should select a file to upload', function() {
// Populate name field (required)
ST.textField('form[title="File Upload Form"] textfield[fieldLabel="Name"]')
.setValue('My Screenshot');
// Find file upload field's HTML element (the actual HTML file upload field)
ST.element('form[title="File Upload Form"] filefield[name="photo-path"] => input[type="file"]')
.get('id')
@DanielGallo
DanielGallo / MouseOver.js
Last active January 28, 2019 20:37
MouseOver on Component in WebDriver scenario (Sencha Test)
// Scenario URL: http://examples.sencha.com/extjs/6.5.3/examples/kitchensink/frame-index.html?classic#locking-grid
describe('Grid column tests', function() {
it('Should lock the Change column', function() {
var driver = ST.defaultContext.driver;
// This code moves the mouse over one of the column's headers which
// shows the trigger to display the column menu
ST.element('gridcolumn[text=Change] => .x-column-header-text-container')
.get('id')
.and(function() {
@DanielGallo
DanielGallo / ReadJSON.js
Created July 10, 2018 15:23
Read JSON file in Sencha Test
describe("Read JSON file", function() {
it("should read the data", function(done) {
var fs = require('fs');
var users;
// Go up 2 folder paths in hierarchy
contextPath = contextPath.substring(0, contextPath.lastIndexOf('/'));
fs.readFile(contextPath + '/test.json', 'utf8', function (err, data) {
if (err) {
@DanielGallo
DanielGallo / Classes.js
Last active July 17, 2018 15:05
Using and checking classes in Sencha Test on Components and Elements
// Scenario URL: http://examples.sencha.com/extjs/6.5.3/examples/kitchensink/?classic#form-contact
describe('Check component and element classes', function() {
it('should check the class applied to a component configuration', function() {
// These examples reference an Ext JS component and check its configured classes
// Example 1
ST.button('form-contact button[text="Contact Us"]')
.get('cls')
.and(function(future) {
expect(future.data.cls).toContain('contactBtn');