- Protractor skip some test conditionally. Example code
Should add ignore function at top, and we call this ignore in it block.
var ignore = function(exp){return{it:((typeof exp==='function')?exp():exp)?function(){}:it}};
describe('Suite 1', function() {
it("test a", function() {
expect(1).toEqual(1);
});
ignore(true).it("test b", function() {
expect(1).toEqual(1);
});
ignore(skip).it("test c", function() {
expect(1).toEqual(1);
});
function skip(){
return true;
}
});
- Protractor test hidden element, deal with hidden elements
var elm = element(by.id("myid"));
browser.executeScript(function (arguments) {
arguments[0].style.visibility = 'visible';
arguments[0].style.display = 'block';
}, elm.getWebElement());
- Protracot to access local Storage
var value = browser.executeScript("return window.localStorage.getItem('key');");
expect(value).toEqual(expectedValue);
- Get value from trustedResourceURL
var trustedResource = $sce.trustAsResourceUrl("www.abcd.com/folder/image.png");
$sce.valueOf(trustedResource); // "www.abcd.com/folder/image.png"
- Goto element in Angular
$scope.gotoBottom = function() {
// set the location.hash to the id of
// the element you wish to scroll to.
$location.hash('bottom');
// call $anchorScroll()
$anchorScroll();
};