博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Cypress] Find and Test Focused Input with Chrome’s DevTools in Cypress
阅读量:5930 次
发布时间:2019-06-19

本文共 1014 字,大约阅读时间需要 3 分钟。

In this lesson, we’ll add tests that finds a focused input. We’ll use Chrome’s dev tools from inside the Cypress runner to inspect the element and update our test to verify that the expected element is focused. We’ll see how Cypress can be used to test drive our application by creating a failing test and updating our application code to make it pass.

 

For exmaple in the todo app, when the page loaded, we want to test, 

  • whether the input field is focused
  • whether the value of input filed is empty
  • whether the placeholder of the input field is "What needs to be done?"

 

 

The component code we have:

import React from 'react'export default props =>  

 

The test code:

form-input.spec.js:

describe('Form input', function () {    it('should has input filed auto focused when page loaded', function () {        cy.visit('/');        cy.focused()            .should('have.class', 'new-todo')            .and('have.attr', 'placeholder', 'What needs to be done?')            .and('be.empty');    });});

 

,

转载地址:http://alktx.baihongyu.com/

你可能感兴趣的文章
使用自定义的确认框代替默认的浏览器的确认框
查看>>
13:整数去重(1.9)
查看>>
JavaScript用typeof判断变量是数组还是对象,都返回object
查看>>
PCB规则设置
查看>>
ROS探索总结(二)——ROS总体框架
查看>>
MySqlday01-数据库基本介绍
查看>>
木兰在线英语词典 -- 溯源拆分记单词
查看>>
顺天乡华人论坛
查看>>
设置Flex中Tree组件默认选中一项
查看>>
Unity项目中文字的统一管理
查看>>
网络层的基本内容
查看>>
提升Android应用视觉效果的10个UI技巧【转】
查看>>
[attribute^=value]和[attribute*=value]的含义(css3)
查看>>
Get和Post区别
查看>>
3.1---一个数组实现三个栈(CC150)
查看>>
python-while循环
查看>>
jQuery自动完成组建Autocomplete
查看>>
bootstrap--- 两种bootstrap multiselect组件大比拼
查看>>
vs2008 x64编译环境 忽略了 #ifdef WIN32
查看>>
HTML5移动Web开发(十)——在浏览器中启动手机原生应用
查看>>