[Cypress] Find and Test Focused Input with Chrome’s DevTools in Cypress
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 =>
<form onSubmit={props.handleTodoSubmit}>
<input
type='text'
autoFocus
value={props.currentTodo}
onChange={props.handleNewTodoChange}
className="new-todo"
placeholder="What needs to be done?"/>
</form>
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');
});
});
[Cypress] Find and Test Focused Input with Chrome’s DevTools in Cypress的更多相关文章
- chrome通过devtools来查看Devtools Extension与浏览器内核实际通信的数据情况
1.chrome通过devtools来查看Devtools Extension与浏览器内核实际通信的数据情况,步骤如下: (1)开启开发者工具实验模式 ---浏览器进入chrome://flags - ...
- [Cypress] Test React’s Controlled Input with Cypress Selector Playground
React based applications often use controlled inputs, meaning the input event leads to the applicati ...
- chrome调试工具DevTools的使用 以及 localhost在移动端不能访问的问题
1.手机和pc 都需要装 chrome浏览器 2.手机端打开开发者模式和usb调试 (华为nova的手机小坑,需要选择usb 配置为可传输文件的状态) 3.经过以上操作打开chrome://inspe ...
- [转]chrome 的devtools 中setting 开启workspace , 也有点用处。不是很大
转载的,原文: http://wiki.jikexueyuan.com/project/chrome-devtools/saving-changes-with-workspaces.html ---- ...
- Chrome Vue Devtools插件安装和使用
安装:fq后在chrome应用商店搜索 Vue Devtools并安装,安装成功后浏览器右上角有vue的图标 安装完毕后,打开含有vue框架的网站,这是vue图标会变亮,进入开发者工具,再右侧vue选 ...
- 在Chrome与火狐中,输入框input类型为number时,如何去除掉的自带的上下默认箭头
如何移除input='number'时浏览器自带的上下箭头: CSS样式: /* 去除input[type=number]浏览器默认的icon显示 */ input::-webkit-outer-sp ...
- puppeteer(五)chrome启动参数列表API
List of Chromium Command Line Switches https://peter.sh/experiments/chromium-command-line-switches/ ...
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part2
Use Cypress to test user registration Let’s write a test to fill out our registration form. Because ...
- 屏幕分辨率测试工具(舍弃)---chrome开发者工具devTools(强烈建议系统学习)
2019-01-25 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...
随机推荐
- spring 监听器 IntrospectorCleanupListener简介
转自:https://blog.csdn.net/ywb201314/article/details/51144256 其中JavaBeans Introspector是一个类,位置在Java.bea ...
- pair类型 这次遇到了,记录下来,方便彼此xue习
首先,这个pair类型是在头文件utility.h中. 一个piar保存两个数据成员,是用来生成特定类型的模板,当创建一个pair时,我们必须提供两个类型名,pair的数据成员将具有对应的类型,两个类 ...
- Largest Rectangle in a Histogram(dp)
http://acm.hdu.edu.cn/showproblem.php?pid=1506 题意:给出n个矩形的高度,每个矩形的宽都为1,求相邻的矩形能组合成的最大的矩形的面积. 思路:求出比第i个 ...
- poj3071Football(概率期望dp)
Football Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5620 Accepted: 2868 Descript ...
- selenium3 + python - expected_conditions判断元素
expected_conditions 类 title_is: 判断当前页面的title是否完全等于(==)预期字符串,返回布尔值 title_contains : 判断当前页面的title是否包含预 ...
- TopK代码
Hash表 #ifndef _HASH_H #define _HASH_H #include<string.h> #include<stdio.h> class HashTab ...
- POJ 3253 STL优先队列
题目大意:FJ需要修补牧场的围栏,他需要 N 块长度为 Li 的木头(N planks of woods).开始时,FJ只有一块无限长的木板,因此他需要把无限长的木板锯成 N 块长度 为 Li 的木板 ...
- javascript事件绑定1-模拟jquery可爱的东西
1.给对象添加事件attachEvent(兼容IE,不兼容ff.chrome) <html xmlns="http://www.w3.org/1999/xhtml"> ...
- 2A课程笔记分享_StudyJams_2017
课程2A 概述 课程2A.2B的内容主要是关于创建交互式应用的基础知识.之前的L1课程主要是Android UI的基础设计知识,基本上没涉及到编程. 2A的讲解主要包括:使用变量来更新欲显示在屏幕上的 ...
- “发布后tomcat中的classes目录为空”问题
办法:Project-clean,ok,问题解决.