Cypress- automated testing - Syntax

cypress in my mind, is easier to understand than selenium. More accurate positioning, each step has generated snapshots, easy to view the results.

cypress and other UI automated testing tools, to be able to locate the very beginning to the interface elements. The method of locating interface elements, I had the impression that the use of xpath, coordinate positioning, document, but often it is easy to interface a few changes affecting the operation of the code. So cypress here to do some improvements. Avoid positioning interface elements fail.

1] cypress positioning elements

  1, cy.get (selector), selector DOM element.

Instructions:

  2、contains(content)

             contains (selector, content), content is the text of the DOM

Instructions:

When there is one thing to note is that the text must be the only value of the current page, current page with the same text multiple values, cypress only match the first text.

  3, when the positioning field in the list, can be used cy.get ( 'form> div> tr> td') is positioned to the first line of the first value.

  4, there is no element to target a unique value, may be positioned according to the context. For example cy.get (id) .next () may be positioned to the next element get ( '# id') elements.

              cy.get ( '# id'). children () to locate the child element.

    cy. get ( '# id'). children (). first () to locate the first subelement.

Click 2]

.click () Click

.click ({force: true}) Click forced

.dbclick () Double-click on

3] write

.type(text)

4] affirm

.should (chainers), chainers represents a specific statement

.should (chainers, value) represents the expected value assertion

.should (chainers, method, value) is generally used for element attribute value assertion

Above syntax cypress operation of the UI interface, of course, when the front desk if the code does not regulate, to find elements of the things some dues, but also by the context of the elements can be positioned.

 

Guess you like

Origin www.cnblogs.com/memebuguoshixingfu/p/11808582.html