Struggling with accessing code from the browser console? Specifically, encountering issues with a Tawk_Api function Tawk_API.hideWidget();
. Attempts to utilize browser execute and call have resulted in an error message stating that Tawk.Api is not defined.
Here's an example of the code:
var expect = require('chai').expect;
function HideTawk (){
Tawk_API.hideWidget();
}
describe('', function() {
it('should be able to filter for commands', function () {
browser.url('https://arutech.ee/en/windows-price-request');
$('#uheosaline').click();
browser.execute(HideTawk());
var results = $$('.commands.property a').filter(function (link) {
return link.isVisible();
});
expect(results.length).to.be.equal(3);
results[1].click();
expect($('#getText').getText()).to.be.equal('GETTEXT');
});
});
Updated working function:
function HideTawk (){
return new Promise(function(resolve, reject) {
Tawk_API.hideWidget();
})
}
Furthermore, using browser.execute(HideTawk())
is incorrect; it should be replaced with browser.call(HideTawk());
.
For more information, check out the documentation: