How to fix "Cannot read property 'apply' of undefined" trying to get the location using Protractor? - jasmine

I'm trying to get an element's location using the Protractor (v6.0.0) method call getLocation(), however I'm getting the following exception:
TypeError: Cannot read property 'apply' of undefined
at <Jasmine>
at actionFn (/usr/lib/node_modules/protractor/built/element.js:95:44)
at <Jasmine>
at actionResults.getWebElements.then(/usr/lib/node_modules/protractor/built/element.js:468:44)
at <Jasmine>
at ElementArrayFinder.applyAction_(/usr/lib/node_modules/protractor/built/element.js:466:29)
Any clue how to resolve the issue?
Actually my code is really simple.
it('should compare login page with a baseline', async () => {
let input = element(by.id('mat-input-1'));
await input.getLocation();
});
I expect the coordinates of the input which has id mat-input-1, but unfortunately I'm getting that exception.

Protractor's CHANGELOG.md has a link to the selenium-webdriver CHANGELOG, it lists:
Changes for W3C WebDriver Spec Compliance
Replaced WebElement.getSize() and WebElement.getLocation() with a
single method, WebElement.getRect().
So it looks like you should use .getRect().
Now for Protractor 6 itself, this is clearly an issue with documentation. We recommend using 5.4.2 for now.

Related

Cannot read property 'sumo' of undefined

I have a sumoselect field with active multiple choices. The input is correctly loaded and it works. I have a problem with methods. I get the undefined error Uncaught TypeError: Cannot read property 'sumo' of undefined.
For example this works
$('.js-selectsumo-filter').SumoSelect();
and this returns the error
$('js-selectsumo-filter')[0].sumo.unload();.
Sumoselect.js is first initialized and afterwards I call my custom js file. I am using jQuery 3.3.1.
$('.js-selectsumo-filter').SumoSelect({
placeholder: placeholder,
csvDispCount: 5,
selectAll: false,
search: true
});
I've managed to find a solution how to call a method without click function as shown in the documentation.
$('.your-class-or-id').SumoSelect().sumo.selectItem('test');
selectItem can be exchanged for any other method available.

Why do I get error when trying to add file attachments?

I am trying to use the method addFileAttachmentAsync() in office.js library.
This is the signature of the method I am using:
item.addFileAttachmentAsync(uploadLink, fileJson.name, { asyncContext: null }, function (asyncResult) { });
uploadLink is a string and here is an example of a file I'm trying to upload: https://xdr.purequad.com:6443/files/1b783908-a259-4839-93e2-18fe3248b943_moto.pdf.xdr
The file above is about ~3MB, but when I use a file under 1MB everything works perfectly.
Afterwards it throws this Exception :
Line: 9
Error: Unable to get property 'isInstanceOfType' of undefined or null reference
Also I have to mention this behavior happens only in IE11, while Google Chrome does not throw any exception at all and still does not work.
EDIT: The function was being interrupted before it ended properly! Check my comment.
I have solved the issue myself. When using addFileAttachmentAsync() because it's an async call one should never interrupt the task-pane with Office.context.ui.closeContainer() which was my case. Otherwise it will generate unexpected behavior.

Angular2-meteor cant read property "meteorInstall"

I'm converting an old angular2 project over to use meteor to act as an admin panel style thing for a project that is based off the ionic2-meteor whatsapp tutorial.
So I'm building the website in the client folder inside api.
I'm pretty sure I've got things correct (based off the old socially tutorial) for the angular2 client.
I'm getting these as errors though.
modules.js:13538 Uncaught SyntaxError: Unexpected token export
es5-shim.js:17 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
at es5-shim.js:17
at es5-shim.js:2789
promise.js:17 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
at promise.js:17
at promise.js:582
ecmascript-runtime.js:17 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
at ecmascript-runtime.js:17
at ecmascript-runtime.js:4630
babel-runtime.js:17 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
at babel-runtime.js:17
at babel-runtime.js:160
random.js:18 Uncaught TypeError: Cannot read property 'meteorInstall' of undefined
at random.js:18
at random.js:368
I imagine that I have probably missed an import or something somewhere but can't work out where.
Any help would be awesome.
These are the packages I have installed.
meteor-base#1.0.4
mobile-experience#1.0.4
mongo#1.1.15
reactive-var#1.0.11
jquery#1.11.10
tracker#1.1.2
standard-minifier-css#1.3.3
standard-minifier-js#1.2.2
es5-shim#4.6.15
ecmascript#0.6.3
shell-server#0.2.2
angular2-compilers
barbatus:typescript
accounts-base#1.2.14
npm-bcrypt#0.9.2
accounts-password#1.3.4
reywood:publish-composite
http#1.2.11
alanning:roles
check#1.2.4
dispatch:mocha-phantomjs
tmeasday:publish-counts
hwillson:stub-collections
practicalmeteor:mocha
xolvio:cleaner
~Edit
///the error comes from #angular/http module, I'm going to try rolling it back to see if it helps.
/**
* \#experimental
*
*/
export var QueryEncoder = (function () {//<---- this is the line causing the error
function QueryEncoder() {
}
QueryEncoder.prototype.encodeKey = function (k) { return standardEncoding(k); };
QueryEncoder.prototype.encodeValue = function (v) { return standardEncoding(v); };
return QueryEncoder;
}());
rolling back and forward didn't help at all.
I had the same problem. For me it was due to recently installed ionic plugin. It has started working normal after removing that plugin. Please try removing your recently added plugin. I hope you have tried that by now.

VoltRB rspec testing a method can't convert Promise into Array

I am trying to do some rspec unit tests on a method in my model. The method returns a promise, and when resolved, the name of the person. The method is not the problem as I know that it works correctly. Here is my test code:
it 'should return correct name' do
report = Report.new(first_name: 'Testy', last_name: 'Testerson')
report.save!
expect(report.name).to eql('Testy Testerson')
end
When I test it, I get the following error:
Failure/Error: expect(report.name).to eql('Testy Testerson')
TypeError:
can't convert Promise to Array (Promise#to_ary gives Promise)
While debugging, I used the following line to inspect the returned value of the method:
puts report.name.inspect
And I got the following response:
#<Promise(70319926955580): "Testy Testerson">
The error seems to be happening because it tests the promise against the expected value. Why am I getting this error?
Using report.name.value fixes this issue
When running code on the server, calls to store return a promise that is already resolved. But on the client the promise won't be resolved yet. Someone (forget the name atm) is working on adding support to promise directly into opal-rspec, but at the moment a returned promise won't wait for opal-rspec. The plan is once thats ready we'll add more tools to volt to make it easier for developers to test in both MRI and opal (like we do with Volt itself).
You can call .value on a promise to get back its value, but only if the promise has resolved. The safer way to do it is to use a .then block:
report.name.then do |name|
expect(name).to eq('Bob')
end
Hopefully that helps.

Capybara debug, don't even know where has this error

I am debugging, then the error message pop up like following:
http://127.0.0.1:56121/apps/quicktip/quicktip_model.js|84|=============================checkShownBefore
Started request to "http://127.0.0.1:56121/apps/quicktip/ejs/quicktip.ejs"
Received 200 from "http://127.0.0.1:56121/apps/quicktip/ejs/quicktip.ejs"
http://127.0.0.1:56121/apps/quicktip/quicktip_model.js|31|=============_setTip
http://127.0.0.1:56121/apps/quicktip/quicktip_controller.js|153|======================currentTip
http://127.0.0.1:56121/apps/quicktip/quicktip_controller.js|153|==============finish currentTip
http://127.0.0.1:56121/apps/quicktip/quicktip_model.js|31|=============_setTip
http://127.0.0.1:56121/apps/quicktip/quicktip_controller.js|153|======================currentTip
http://127.0.0.1:56121/apps/quicktip/quicktip_controller.js|153|==============finish currentTip
undefined|0|TypeError: 'undefined' is not a function
It didn't even mention which file is complaining the type error, I tried to use console.log in quicktip_controller.js, to see whether there is anything wrong after this page. But I can get nothing. Any suggestion??
Suggestion is that the undefined is valid in js, but invalid for pure rails environment. So you haveto look into apps/quicktip/ejs/quicktip.ejs or around files for the occurines of undefined keyword in ruby code.

Resources