TestCafe - Test fails onGetBposShellInfoNavBarData - testing

I am running TestCafe version 0.22.0 on Win10. I am not sure if my issue has something with the Win10 or not but unfortunately, I don´t have another computer to test on. The issue is that my tests fail with error message "GetBposShellInfoNavBarData failed: SyntaxError: Unexpected end of JSON input"
Here is the simple code I use:
Error on page "https://outlook.live.com/mail/inbox": GetBposShellInfoNavBarData failed: SyntaxError: Unexpected end of JSON input
Browser: Chrome 69.0.3497 / Windows 10.0.0
await t.click('body > section > div > div > nav > div > div > div > a');
await t.typeText('#i0116', login);
await t.click('#idSIButton9');
await t.typeText('#i0118', password);
await t.click('#idSIButton9');
await t.maximizeWindow();
Test fails on this t.maximizeWindow(). It also fails with same error on next "t.click(Selector...) if I comment out t.maximizeWindow() line.

As #ioseph properly mentioned, this error occurs on your web page and is not related to TestCafe.
I recommend that you address this error on your website and run your tests again.
Alternatively, you can use the --skip-js-errors argument to ignore such errors.

Related

Clicking element once gives error, clicking it twice works fine, why? (Protractor)

I'm running end-to-end tests on a website with Protractor, and one of the elements is having a strange behavior. When I first tried specifying the code to click the element once, I got the following error.
Problematic function:
fooField = element(by.css('#inputFoo'));
foosList = $$('[type=radio]');
async chooseFoo(id: number) {
const foo = this.foosList.get(id - 1);
// await browser.sleep(2000);
// await this.fooField.click();
await this.fooField.click();
await browser.sleep(this.sleepTime);
await foo.click();
await this.selectFooButton.click();
}
Error:
**************************************************
* Failures *
**************************************************
1) reimbursement request page should allow a user to register a request
- Failed: element not interactable
(Session info: chrome=72.0.3626.81)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.15.0-45-generic x86_64)
Executed 2 of 2 specs (1 FAILED) in 28 secs.
[16:50:44] I/launcher - 0 instance(s) of WebDriver still running
[16:50:44] I/launcher - chrome #01 failed 1 test(s)
[16:50:44] I/launcher - overall: 1 failed spec(s)
[16:50:44] E/launcher - Process exited with error code 1
An unexpected error occurred: undefined
After changing the code to click on the element twice in a row, and changing nothing else, the code ran successfully. I also tried removing the redundant click and adding a sleep right before the click, but I still got the same error. Why is this happening?
Not sure which element you're trying to click, but this way of clicking has helped me when having similar problems:
browser.executeScript('arguments[0].click()', elementToClick);
let fooField = element(by.css('#inputFoo'));
await browser.wait(ExpectedConditions.elementToBeClickable(fooField), 5000, 'Element is not clickable.');
await fooField.click();
If the element is not clickable after the certain time will throw error, there is a problem with the button. Something is blocking it, to be clicked.
Another way to bypass it (not the best way) is using javascript click.
let fooField = element(by.css('#inputFoo'));
browser.executeScript('arguments[0].scrollIntoView(true); arguments[0].click();', fooField);

selenium-server won't `setValue`

I'm using selenium-server version 3.0.1 and nightwatch version ^0.9.12 on node 8.9.0. My e2e test do run, clicks work, and reading the DOM works, but setValue just doesn't.
For example, the following test:
browser
.url("...")
.waitForElementPresent('select[name=foo]', 5000)
.click('select[name=foo] option:nth-child(2)')
.waitForElementPresent('input[name=bar]', 5000)
.setValue('input[name=bar]', "hello world")
.getValue('input[name=bar]', function(input) {
this.assert.equal(input.value, "hello world");
})
.end();
will open the url, wait for foo and click the second option. It will wait for bar, then fails:
Running: test
✔ Element <select[name=foo]> was present after 24 milliseconds.
✔ Element <input[name=bar]> was present after 28 milliseconds.
✖ Failed [equal]: ('' == 'hello world') - expected "hello world" but got: ""
at Object.<anonymous> (/test/e2e/specs/test.js:49:21)
FAILED: 1 assertions failed and 2 passed (4.692s)
_________________________________________________
TEST FAILURE: 1 assertions failed, 2 passed. (4.9s)
✖ test
- run through apply process (4.692s)
Failed [equal]: ('' == 'hello world') - expected "hello world" but got: ""
If I replace the setValue with a delay and enter a value by hand, the test will pass, so getValue is working.
This does run, and pass, on other systems, but I can't get it working on my own so I think it's a selenium-server issue.
I've tried a lot of the 101 fixes, clearing the npm cache, re-running an npm install, etc. But with no errors other than the failure, how do I debug this?
Assuming you are trying to test using Chrome, you need to update your ChromeDriver.
Chrome 65 was released recently and older ChromeDriver versions are apparently incompatible with it.
Download the latest one from the downloads page.
Make Nightwatch use it, nightwatch.json -
{
...
"selenium": {
...
"cli_args": {
"webdriver.chrome.driver": "path/to/chromedriver.exe"
Assuming Nightwatch uses it (you can see which one it uses using the Windows Task Manager - assuming you are using Windows - look for the command line of chromedriver.exe), setValue should now work again.
The error says it all :
Failed [equal]: ('' == 'hello world') - expected "hello world" but got: ""
In your code block you have induced wait for the WebElement identified as 'input[name=bar]' and next invoked setValue() which is successful as follows :
.waitForElementPresent('input[name=bar]', 5000)
.setValue('input[name=bar]', "hello world")
Now the JavaScript associated with this WebElement identified as 'input[name=bar]' will require some time to render the value within the HTML DOM. But in you code block you are trying to access the entered value (in the previous step) too early. Hence your script finds <null> as the value.
Solution
You need to induce a waiter i.e. expect clause for the value to be rendered within the HTML DOM through the associated JavaScript as follows :
.waitForElementPresent('input[name=bar]', 5000)
.setValue('input[name=bar]', "hello world")
.expect.element('input[name=bar]').to.have.value.that.equals('hello world');
.getValue('input[name=bar]', function(input) {
this.assert.equal(input.value, "hello world");
})

Selenium test fails when running phantomjs

I using nightwatch framework for running End-to-End test. I am able to run all the test cases successfully in chrome and IE but few tests fails for phantomjs. Test cases below error out
'Search' : function(browser) {
browser
.url('http://localhost:8001/index.html')
browser
.setValue('input[id=SearchInput-inner]', 'abc')
.click('button[id=nsnButton]')
.pause('1000')
.verify.attributeEquals('#nsnButton', 'disabled', 'true')
},
Error I get is
Testing if attribute disabled of <#nsnButton> equals "true". Element does not have a disabled attribute. - expected "true" but got: "null"
other test that fails is
.getCssProperty('#SearchInput-inner', 'border-color', function(result) {
this.verify.equal(result.value, '#ee0000');
})
Error I get is Failed [equal]: ('rgb(238, 0, 0)' == '#ee0000') - expected "#ee0000" but got: "rgb(238, 0, 0)"
How Can I handle this situation where same test works for ie and chrome but fails for phantomjs.
Thanks

How to use spiderable with a meteor app hosted on modulus.io

I'm trying to make spiderable works on my meteor app hosted on modulus with SSL.
I have Meteor 1.0, iron:router 1.0, spiderable and node package of phantomjs
All is working on localhost. But once I deploy on Modulus, first I had the error
spiderable: phantomjs failed: null
Then, I added the following environment variable in the modulus panel:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ssl-protocol=tlsv1 --ignore-ssl-errors=yes --debug=true
This is still not working and the debug is outputting multiple times (like it's looping over an error) the following message in the modulus console:
2014-12-03T17:01:00 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function () {
if (typeof Meteor === 'undefined'
|| Meteor.status === undefined
|| !Meteor.status().connected) {
return false;
}
if (typeof Package === 'undefined'
|| Package.spiderable === undefined
|| Package.spiderable.Spiderable === undefined
|| !Package.spiderable.Spiderable._initialSubscriptionsStarted) {
return false;
}
Tracker.flush();
return DDP._allSubscriptionsReady();
})(); })()"
2014-12-03T17:01:00 [DEBUG] WebPage - evaluateJavaScript result QVariant(bool, false)
If anyone knows how to solve this or succeeded to deploy a meteor project on modulus.io with SSL and spiderable. Let's me know the good way to do it :)
Thank a lot !
I solved my problem as follows:
I installed phantomjs locally and run the test script available at http://www.meteorpedia.com/read/spiderable/
phantomjs phantomtest.js
This gave me more details about the error: Parse Error.
Then, it was a javascript file that once compiled/minified, rendered an error caused by select2. The js library that was using it was flat-ui.js (http://designmodo.github.io/Flat-UI/).
I discover this by testing many deploys on *.meteor.com and by adding/removing .js file.
I edit the flat-ui.js library to avoid Parsing Error.
I redeployed on both modulus.io and *.meteor.com. All was working fine on *.meteor.com but still didn't work on modulus.io. That let me thinking about an SSL error but I only saw "spiderable: phantomjs failed: null" in the modulus.io logs.
I add the following environment variable in the modulus panel:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --debug=true
and it appears that it was a "SSL Handshake error":
[DEBUG] Network - Resource request error: 6 ( "SSL handshake failed" )
I add another option to the METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS environment variable:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ignore-ssl-errors=yes --debug=true
Now everything is working fine on modulus.io.
To sumup:
solve javascript errors
add METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ignore-ssl-errors=yes
I hope this will help some dudes,

CasperJS "Syntax error: Parse error"

I've just been starting to experiment with CasperJS for some testing purposes, but I'm apparently pretty crappy at it because I've isolated my code down to the very first task,:
"use strict";
var casper = require('casper').create({
verbose: true,
logLevel: 'debug'
waitTimeout: 10000
});
phantom.cookiesEnabled = true;
casper.start('http://foobar.com', function afterstart() {
if (this.exists('.logo-link')) {
this.echo('BOOYA! Page is loaded', 'INFO');
} else {
this.echo('Page didnt load, something went all screwy.', 'ERROR');
}
});
casper.run();
run it through a linter, made the appropriate changes, and I still get this error:
Test file: Test.js
FAIL SyntaxError: Parse error
# type: uncaughtError
# error: "SyntaxError: Parse error"
SyntaxError: Parse error
FAIL 1 tests executed in 0.103s, 0 passed, 1 failed.
Details for the 1 failed test:
In Test.js:0
uncaughtError: SyntaxError: Parse error
I've looked up some possible explanations, I added the phantom.cookiesEnabled = true, but I simply can't figure it out.
Two best answers taken from similar question getting more information from phantomjs "SyntaxError: Parse error" message are:
1) run it with node:
node Test.js
2) use online syntax checker like http://esprima.org/demo/validate.html
You're missing a comma:
logLevel: 'debug' <--- Right here
waitTimeout: 10000