[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:// ...
随机推荐
- Coursera Algorithms week2 栈和队列 练习测验: Stack with max
题目原文: Stack with max. Create a data structure that efficiently supports the stack operations (push a ...
- z-index 、层叠上下文、层叠级别、z-index失效
一.z-index z-index默认处于非激活状态,只有定位元素(即position:relative/absolute/fixed时)才会被激活. z-index与层叠上下文关联. 当z-inde ...
- 昂贵的聘礼(Dijkstra)
http://poj.org/problem?id=1062 每个物品看成一个节点,酋长的允诺也看作一个物品, 如果一个物品加上金币可以交换另一个物品,则这两个节点之间有边,权值为金币数,求第一个节点 ...
- 【LOJ#10115,tyvj1473】校门外的树(第3次升级)
PS:思路来源于Clove_unique的博客,在此万分感谢 这道题可以用树状数组轻松过,然而...树状数组不太熟悉,还是用线段树比较好(虽然代码比较长) [思路分析] [一开始的思路] 最开始的错误 ...
- JQuery 数据加载中禁止操作页面
比较常见的做法,但对我而言是第一次做,记录一下. 为了把找来的loading.gif 的背景色设置为透明,还特意装了quicktime. 有学到一些额外的东西. 先将div及img定义好 <bo ...
- 错误:android.view.InflateException: Binary XML file line #167: Binary XML file line #167: Error inflating class <unknown>
1:错误日志 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.8.activity.RecordActiv ...
- POJ 1000
#include <iostream> int main() { using std::cin; using std::cout; using std::endl; int a,b; ci ...
- java将父类所有的属性COPY到子类中
public class FatherToChildUtils { /* * 将父类所有的属性COPY到子类中. * 类定义中child一定要extends father: * 而且child和fat ...
- java模拟Cookies登陆
在使用java访问URL时,如果该URL需要身份验证,那么就不能够直接访问,因为没有登陆.那么,如何解决这个问题呢? 方法是使用java模拟登陆,登陆后记录下cookie信息,在下次发起请求时时将co ...
- 团体程序设计天梯赛-练习集-L1-044. 稳赢
L1-044. 稳赢 大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示: 现要求你编写一个稳赢不输的程序,根据对方的出招,给出对应的赢招.但是!为了不让对方输得太惨,你需要每隔K ...