Skip to content

Instantly share code, notes, and snippets.

View DanielGallo's full-sized avatar

Daniel Gallo DanielGallo

View GitHub Profile
@DanielGallo
DanielGallo / SwitchTabs.js
Last active September 26, 2019 22:45
Shows how to handle and switch multiple tabs in Sencha Test
// WebDriver scenario URL: https://examples.sencha.com/extjs/6.7.0/examples/kitchensink/frame-index.html#link-buttons
describe('Switching tabs', function() {
var tabIds, driver;
beforeAll(function() {
// This stores a reference to the underlying driver object
driver = ST.defaultContext.driver;
});
// Scenario URL: http://examples.sencha.com/extjs/6.5.3/examples/kitchensink/frame-index.html#array-grid
describe('Grid', function() {
it('should click a button on a grid row and check the popup message contains the clicked record name', function() {
var recordName;
// Locate the grid
ST.grid('array-grid')
.rowAt(2)
.getRecord()
.and(function(future) {
@DanielGallo
DanielGallo / Grid.js
Created July 31, 2018 16:40
Getting and storing a grid cell value
// Scenario URL: http://examples.sencha.com/extjs/6.5.3/examples/kitchensink/?classic#array-grid
describe('Grid', function() {
var recordTitle;
it('should get the cell text content', function() {
// Use the "getRecord" API to get a record's value
ST.grid('grid[title="Basic Grid"]')
.rowAt(1)
.getRecord()
@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');
@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 / 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 / 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 / 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 / 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 / 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'