Protractor – elementexplorer.js

elementexplorer.js is a bonus tool from protractor that helps you debug your selectors on page objects live! It’ll make your life on writing protractor tests a lot easier! This post assumes that you have worked with protractor before and have it installed on your machine.

Start selenium

Before starting elementexplorer.js, you need to first start selenium:

> webdriver-manager update
> webdriver-manager start

# or you can start webdriver with a specific port; default is 4444
> webdriver-manager start --seleniumPort XXXX

In the browser opened by selenium, navigate to your angular web app.

Assuming that you have the following binding in your application:

$scope.yourName = "Wahaha" 
<input ng-model="yourName" />

 

Use elementexplorer

Open a new terminal. Then locate it in node_modules folder and run the following command

> ./node_modules/protractor/bin/elementexplorer.js

Using list() in elementexplorer:

> list(by.model('yourName'))
['']

> list(by.model('notExisted'))
[]

> list(by.binding('yourName'))
['Wahaha']  //Note: this value can be changed on page

 

Reference:

How To Master The Perfect Voice

The referenced video of this post is an interview done by Stefan James with Roger Love.

Just to take note and apply it to my next speaking sessions, here are the three main points that may immediately applicable for me:

1. Three range of tone of speaking to make the talk more interesting: (should be lower and slower for me)

2. Pause and breathe in with nose instead of mouth between sentences or commas.

3. Don’t limit my voice to the microphone; Project my voice to vibrate the bodies of the far audience.

 

Self-confidence Formula

1. I know that I have the ability to achieve the object of my Define Purpose in life. Therefore I demand of myself persistent, continuous action towards its attainment, and I here and now promise to take such action.

2. I realize the dominating thoughts of my mind will eventually reproduce themselves in outward, physical action and gradually transform themselves into physical reality. Therefore I will concentrate my thoughts for 30 minutes daily upon the task of thinking of the person I intend to become, thereby creating in my mind a clear mental picture fo that person.

3. I know through the principle of autosuggestion that any desire I persistently hold in my mind will eventually seek expression through some practical means of attaining the object. Therefore I will devote 10 minutes daily to demanding of myself the development of self-confidence.

4. I have clearly written down a description of my Definite Chief Aim in life. I will never stop trying until I have developed sufficient self-confidence for its attainment.

5. I fully realize that no wealth or position can long endure unless built upon truth and justice. Therefore I will engage in no transaction that does not benefit all whom it affects. I will succeed by attracting myself the forces I wish to use, and the cooperation of other people. I will induce others to serve me because of my willingness to serve others. I will eliminate hatred, envy, jealousy, selfishness and cynicism by developing love for all humanity because I know that a negative attitude towards others can never bring me success. I will cause others to believe in me, because I will believe in them, and in myself. I will sign my name to this formula, and commit it to memory and repeat it aloud once a day, with full faith that it will gradually influence my thoughts and actions so that I will become a self-reliant and successful person.

 

This post is extracted from “Think and Grow Rich by Napoleon Hill p53”

ES8 – Callback, Promise and Async

Callbacks: Pass in a function as a parameter

function fetchData(callback) { 
    callback(); 
}

 

Promise: States: Pending, Fulfilled, Rejected

function fetchData() { 
    return new Promise((resolve, reject) => { 
        resolve(rides), 

        // if error:
        reject(errorInfo)
    });
};

 

Promise.all:
takes multiple promises and returns a promise which resolves when all supplied promises are done.

Promise.race:
takes multiple promises and resolves when the first promise is done.

 

async()


// Running sequentially: asyncFunc1 is run before asyncFunc2
async () => { 
    await asyncFunc1(); 
    await asyncFunc2(); 
}


// Running in parallel
async () => { 
    await Promise.all([asyncFunc1(), asyncFunc2()]); 
}

 

ES8 – Array and Exponent

ES8 aka. ES2017

Array.prototype custom function (review)

let number = [1, 2, 3, 4]; 
let moreNumbers = new Array (1, 2, 3, 4); 

Array.protype.count = function() { 
    return this.length;
}

console.log(numbers.count());     // outputs 4
console.log(moreNumbers.count()); // outputs 4

 

Array.prototype.includes

Check if an array contains a specific value and returns a boolean.

let letters = ['a', 'b', 'c', NaN]; 
letters.includes('b');      // true
letters.includes('d');      // false

// includes is similar to indexOf from older version 
letters.indexOf('b') >= 0   // true

// when includes and indexOf is different: 
letters.includes(NaN)       // true
letters.indexOf(NaN) >= 0   // false

 

Exponential syntax: **

3 ** 4 = Math.pow(3, 4)