Cypress常用API

.get() 获取元素

.clear() 清空输入框

.focus() .focus(options)获取焦点

.type(text) .type(text, options) 输入值

.click() 左键单击,如果页面被遮挡可能click失败,可以用click({ force: true })方式强制执行。

.wait() 等待,单位是毫秒,cy.(3000)即等待3秒。如果页面响应慢,可以调整等待时长。

.url() 获取url

.should().and()一样用来写断言,.should('contain','abc').and('mathc','bcd')

.fixture() 取文件中的数据,默认文件path为cypress/fixtures

  cy.fixture(filePath)

  cy.fixture(filePath, encoding)

  cy.fixture(filePath, options)

  cy.fixture(filePath, encoding, options)

.then() Enables you to work with the subject yielded from the previous command.

  .then(callbackFn)

  .then(options, callbackFn)

 cy.clearCookies()清除全部cookie 此外还有:cy.clearCookies(options)

cy.clearLocalStorage() 清除全部LocalStorage,此外还有: cy.clearLocalStorage(key) cy.clearLocalStorage(options) cy.clearLocalStorage(keys, options)

posted @ 2020-09-24 16:25  蜗牛果果  阅读(366)  评论(0编辑  收藏  举报