Where do I see Testcafe Studio console log errors? - testing

Where do you read console log messages in testcafe studio?
I am writing this code;
var image = await getImageElement(
Selector('.call-to-action__image'
).nth(1).nth(1).nth(1).find('a').find('img'));
console.log(image.src);
console.log(image.alt);
await t.debug()
.expect(isEmpty(image.src)).eql(true,"Ribbon does not exist")
.expect(isEmpty(image.alt)).eql(false,"Ribbon does not exist");
This code is for trying to read which value of src or alt the element gets.
Thanks

At this moment, you can not read the console.log messages in TestCafe Studio. However, you can get the console.log result in your terminal if you run your testfile using the TestCafe Open Source.
Please read the following article to get more details about installation and running TestCafe Open Source:
https://devexpress.github.io/testcafe/documentation/using-testcafe/installing-testcafe.html

Related

VSCode Extension User Input Passward

I am trying to develop a VSCode Extension that requires user passward to run a command on the terminal. I have tried this but it throws an irrelevant error.
const readline = require('readline');
const reader = readline.createInterface({
input: process.stdin,
output: process.stdout
});
reader.question("Enter: ", passward=>{
reader.close();
});
Clearly, I am placing it wrong or something else because it runs fine in an individual node js file. I am placing it inside of registercommand
If by run a command in the Terminal you mean that some command should be displayed/added in VS Code terminal, then you should look at the Terminal API in VS Code.
There is a sample in https://github.com/microsoft/vscode-extension-samples/tree/main/terminal-sample, and it will probably help you better understand how to integrate with VS Code terminal.
Hope this helps

Element inaccessible via Cypress Test Runner that is accessible via a regular browser

Click here for image that compares the two different results returned for the same javascript command.
On the left is the image of the web page run inside Cypress Test Runner.
On the right is the image of the web page is a regular browser.
To produce the same result :
In standalone Chrome, load this url, open dev tools and then run the javascript command shown below.
document.querySelector('body#google-amp-body > amp-analytics:nth-child(3) > script')
Copy the following code into a spec file and run it inside Cypress Test Runner. Then open dev tools in the Test Runner window and run the same javascript command. You won't get anything back for this use case. See above screenshot to get a visual sense of what I mean.
If I try to perform cypress tests based on that element in Cypress I get nowhere because that element cannot be found inside Cypress.
If I access the same element via Python/Selenium code, it works fine.
describe('Gamespot Test', () => {
it('Tests for Video Page', () => {
const url = "https://gamespot.com/amp-videos/rainbow-six-extraction-final-preview/2300-6457072/"
cy.visit(url)
})
})

How to access Downloads folder in taiko automation

I want to verify whether file is downloaded or not after clicking download link.
I am using taiko for automating this task.
I tried to open recent downloads in browser by using these taiko commands goto("chrome://downloads/")
and press(['Control','J']) but both did't work.
Is there any other method to do the same task.And i want know why above commands are not working
Check out this example
You need to first set the download path:
// client function is imported from taiko
await client().send('Page.setDownloadBehavior', {
behavior: 'allow',
downloadPath: downloadPath,
});
You then need to download your file (trigger the action that results in the file getting downloaded - the example uses a click action. And then, after a suitable time has elapsed, you will check the download path that you registered earlier for existence of the file:
expect(path.join(downloadPath, 'foo.txt')).to.exist;

TestCafe: Uncaught ReferenceError: pagespeed is not defined

New to TestCafe.
Expected
Given .js below, expected behavior when running testcafe chrome this.js is to click on the header logo.
Actual
Uncaught ReferenceError: pagespeed is not defined (at the click below).
On our prod site, this error doesn't happen so most likely some configuration (possibly my version of Apache?) but I wanted to make sure there weren't any TestCafe specific issues. Followed installation using the standard docs (npm)
Thanks in advance!
import { Selector } from 'testcafe';
fixture `A set of examples that illustrate how to use Little Passports`
.page `https://xxx.xxdev.us/`;
test('My Company', async t => {
await t.
click('.header-logo');
});
I think I'll currently get around this by adding -e, but I'll keep this open just in case there's something else to consider...
By default, a test fails when there is a JavaScript error on page. The "-e (--skip-js-errors)" parameter allows running tests by skipping this JS error.
To check if there are any errors on your page, open your browser console. If there are any, you can either fix the errors at the application level (a preferable approach) or skip them during test run using the "-e" parameter.

Driving Nightwatch Tests through REPL

I currently have nightwatch.js setup using the vue automated setup. That template is located here.
https://github.com/vuejs-templates/webpack/tree/master/template/test/e2e
Is it possible to run nightwatch assertions through the command line in a REPL like fashion that is available in webdriver.io? Here is a reference to the webdriver feature https://twitter.com/webdriverio/status/806911722682544128
Update, we have moved to using Cypress.io It has made us pretty happy
You can use nightwatch-repl package available on NPM.
https://www.npmjs.com/package/nightwatch-repl
// nightwatch.conf.js
var repl = require('nightwatch-repl');
module.exports = (function (settings) {
repl.init(settings);
...
...
return settings;
})(require('./nightwatch.json'));
Once you run your tests and invoke browser.repl()
you should see the following in your console
Running: Login to dashboard
Type in a command (eg: browser.function()) or type "quit" to exit
repl>