Programming Articles - Page 854 of 3363

What is a Pytest framework?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:01:45

729 Views

Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be known.Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every line of code should be inside a method that should have a name ... Read More

What are some of the rules of creating a CSS expression?

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:54:18

420 Views

There are some rules for creating a CSS expression. The CSS is one of the important locators in Selenium. A customized CSS can be developed with the help of attributes like id, class name, and by the combination of tagname and html attributes.The ways of creating a CSS are listed below −Using a class name html attribute.This will select the web element of that particular class represented by (.)classname.Syntax− driver. find_element_by_css_selector(".name")Here name is the value of the attribute class.Using an id html attribute.This will select the web element of that particular id represented by (#) id.Syntax− driver. find_element_by_css_selector("#search")Here search is ... Read More

How to use regular expressions in a CSS locator?

Debomita Bhattacharjee
Updated on 19-Nov-2021 11:50:54

5K+ Views

We can use regular expressions in a CSS locator. We can identify elements by matching their attributes partially with the help of regular expressions. In CSS, there are multiple methods to achieve this. They are listed below −Using the wild character *. This means the string contains our given text.Syntax− driver.find_element_by_css_selector("input[name*='sel']")It will search the input tag which contains the 'name' attribute containing 'sel' text.Using the wild character ^. This means the string starts with our given text.Syntax− driver.find_element_by_css_selector("input[name^='Tut']")It will search the input tag which contains the 'name' attribute starting with 'Tut' text.Using the wild character $. This means the string ... Read More

How to work with id locator in WebdriverIO?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:51:12

1K+ Views

We can work with the id locator in WebdriverIO. Once we navigate to a webpage, we have to interact with the web elements available on the page like clicking a link/button, entering text within an edit box, and so on to complete our automation test case.For this, our first job is to identify the element. We can use the id attribute for an element for its identification. It is a very useful locator and speeds up the execution of automation tests in comparison to all the locators.In the WebdriverIO code, we have the option to specify the value of the ... Read More

How to perform drag and drop actions in WebdriverIO?

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

1K+ Views

WebdriverIO can perform mouse operations like drag and drop using the dragAndDrop method. With this, we execute clicking and holding events on the present object(source), then pass the object to the target element. Finally, release the mouse.Syntaxlet p = $('#loc') let t = $('#target') p.dragAndDrop(t)Here, p is the source locator and t is the destination locator.Let us perform the drag and drop functionality for the below elements −In the above image, the element with the name - Drag me to my target has to be dragged and dropped on the element - Dropped!.ExampleCode Implementation// test suite name describe('Tutorialspoint application', function(){ ... Read More

How to handle frames in Puppeteer?

Debomita Bhattacharjee
Updated on 19-Nov-2021 10:31:43

3K+ Views

We can handle frames in Puppeteer. The frames in an html code are represented by the frames/iframe tag. Puppeteer can handle frames by switching from the main page to the frame. To work with elements inside a frame, first, we have to identify the frame with the help of locators. The method contentFrame is used to access the elements inside the frame.Syntaxconst f = await page.$("frame[name='frame-bottom']") const m = await f.contentFrame()Let us see the html code of an element inside a frame and obtain the text - BOTTOM inside it.The tagname highlighted in the above image is frame and the ... Read More

How to handle tabs in Puppeteer?

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

354 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

Advertisements