Found 33676 Articles for Programming

How to handle tabs in Puppeteer?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:25:04

319 Views

We can handle tabs in Puppeteer using the below methods −newPage() - We can open a new tab using this method available in the browser object.Syntaxconst p = await browser.newPage()close() - We can close the tab opened using this method.Syntaxawait p.close() close() - We can close all the tabs opened using this method available in the browser object.Syntaxawait browser.close()ExampleCode Implementation//adding Puppeteer library const pt = require('puppeteer') pt.launch().then(async browser => { //browser new page const p = await browser.newPage(); //set viewpoint of browser page await p.setViewport({ width: 1000, height: ... Read More

How to pass more than one header in a request in Rest Assured?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:20:01

9K+ Views

We can pass more than one header in a request in Rest Assured. A web service can accept headers as parameters while making a service call. The headers are represented in a key-value pair.There is more than one way of passing multiple headers in Rest Assured −Passing them in a key-value format using the header method.Syntax Response r = given() .baseUri("https://www.tutorialspoint.com/") .header("header1", "value1") .header("header2", "value2") .get("/about/about_careers.htm");Passing them as a Map using the headers method.Syntax Map m = new HashMap(); m.put("header1", "value1"); m.put("header2, "value2"); Response r = given() .baseUri("https://www.tutorialspoint.com/") .headers(m) .get("/about/about_careers.htm");Passing them as a List using the headers method.Syntax List h ... Read More

How to manage cookies in WebdriverIO?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:14:17

1K+ Views

We can manage cookies in WebdriverIO. A cookie helps to identify a user. It is an efficient technique to pass information from one site session to another or in between sessions of two connected websites.We can add, delete and obtain a cookie with WebdriverIO using the methods −browser.setCookies - this is used to set a single cookie or multiple cookies for the present page. To set a cookie for a page, we have to first launch and be on that page.Syntax browser.setCookies({cookie, cookie.name, cookie.value, cookie.path, cookie.domain, cookie.secure, cookie.httpOnly, cookie.expiry} )Here, a cookie is the cookie object or object array and ... Read More

How to create a Junit report in Cypress?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:01:36

3K+ Views

We can create a Junit report in Cypress. To install the package for the JUnit report, run the command −   npm install cypress-junit-reporter --save-devExampleImplementation in cypress.json{ "reporter": "junit", "reporterOptions": { "mochaFile": "cypress/results/results.xml", "toConsole": true } }If we run multiple tests in a run and wish to have a unique report for individual spec files, we have to add [hash] in the mochaFile parameter in cypress.json.ExampleImplementation in cypress.json to avoid overriding report{ "reporter": "junit", ... Read More

How to create a Mochawesome report in Cypress?

Debomita Bhattacharjee
Updated on 19-Nov-2021 09:54:51

5K+ Views

We can create a Mochawesome report in Cypress. Cypress is bundled with Mocha, so any reports that can be generated for Mocha can also be utilized with Cypress.Mochawesome ReportThe Mochawesome report is one of the most important reports in Cypress. To install mochawesome, run the command −   npm install mochawesome --save-devTo install mocha, run the command −   npm install mocha --save-devTo merge mochawesome json reports, run the command −   npm install mochawesome-merge --save-devAll these packages after installation should get reflected on the package.json file.To merge multiple reports in a single report, run the command −   npm run combine-reportsIn the cypress.json ... Read More

How to perform data-driven testing in Cypress?

Debomita Bhattacharjee
Updated on 19-Nov-2021 09:49:45

356 Views

Cypress data-driven testing is achieved with the help of fixtures. Cypress fixtures are added to maintain and hold the test data for automation. The fixtures are kept inside the fixtures folder (example.json file) in the Cypress project. It basically helps us to get data input from external files.Cypress fixtures folder can have files in JSON or other formats and the data is maintained in "key:value" pairs. All these test data can be utilized by more than one test. All fixture data has to be declared within the before hook block.Syntaxcy.fixture(path of test data) cy.fixture(path of test data, encoding type ) ... Read More

How to upload a file in Cypress?

Debomita Bhattacharjee
Updated on 19-Nov-2021 09:44:28

6K+ Views

We can upload a file in Cypress. To perform the file upload task in Cypress, we have to first install a plugin with the command −npm ins tall –dev cypress-file-uploadOnce the installation is done, we have to add the statement import 'cypress-fileupload' in the command.js file which resides inside the support folder within our Cypress project. Also, we shall add the file that we want to upload within the fixtures folder(Picture.png file).To upload a file, we have to use the Cypress command, attachFile, and pass the path of the file to be uploaded as a parameter to it.ExampleImplementationdescribe('Tutorialspoint Test', function ... Read More

What is a Cypress Alias?

Debomita Bhattacharjee
Updated on 19-Nov-2021 09:39:55

208 Views

Cypress aliases are an important component that has multiple uses. They are listed below −Sharing ContextWe have to use .as() to alias something that we have to share. To alias objects and primitives, Mocha context objects are used. The aliased object can be accessed with - this.*.Mocha by default shares context for all the hooks applicable for the test and the alias properties are flushed post the execution of a test.describe('element', () => {    beforeEach(() => {       cy.wrap('eleone').as('x')    })    context('subelement', () => {       beforeEach(() => {          cy.wrap('eletwo').as('y') ... Read More

What is the Scenario Outline keyword in Cucumber?

Debomita Bhattacharjee
Updated on 18-Nov-2021 12:39:59

589 Views

Scenario Outline is used to replicate the same Scenario with a different data set. Writing the same tests with different values is cumbersome and time taking. For instance, We can club the above two scenarios with the Scenario Outline.Thus, we see that a Scenario Outline should be accompanied by keyword Examples. A Scenario Outline is executed once for each of the rows appearing below the Examples segment.Also, we have seen that the Given step has the delimiter. It points to the header of the Examples table. SpecFlow shall put the values within this table before the task of matching ... Read More

What is the Example keyword in Cucumber?

Debomita Bhattacharjee
Updated on 18-Nov-2021 12:37:56

5K+ Views

We can perform data-driven testing with the help of keyword Examples. We shall also take the help of keyword Scenario Outline to execute the same Scenario over multiple values.The data sets to be taken into consideration shall be passed below the Examples section one after another separated by | symbol. So, if there are three rows, we shall have three test cases executed from a Single scenario.Also, the Given step has the delimiter. It points to the header of the Examples table. SpecFlow shall put the values within this table prior to the task of matching a step with ... Read More

Advertisements