We often only show UI elements as a result of some user interaction. Cypress detects visibility and by default won’t allow your test to interact with an element that isn’t visible. In this lesson, we’ll work with a button that is shown on hover and see how you can either bypass the visibility restriction or use Cypress to update the state of your application, making items visible prior to interacting with them.

For example the delete icon was hidden by default, only show up when you hover over it, to test those hidden element. we need to call:

.invoke('show')
    it('should Delete an item', function () {
cy.server();
cy.route({
method: 'DELETE',
url: '/api/todos/*',
response: {}
}).as('delete'); cy.seedAndVisit(); cy.get('.todo-list li')
.first()
.find('.destroy')
.invoke('show') // Make the hidden button appear
.click(); cy.wait('@delete'); cy.get('.todo-list li')
.should('have.length', 3);
});

[Cypress] Interact with Hidden Elements in a Cypress Test的更多相关文章

  1. [Cypress] Test Variations of a Feature in Cypress with a data-driven Test

    Many applications have features that can be used with slight variations. Instead of maintaining mult ...

  2. [Cypress] Wait for XHR Responses in a Cypress Test

    When testing interactions that require asynchronous calls, we’ll need to wait on responses to make s ...

  3. [Cypress] Load Data from Test Fixtures in Cypress

    When creating integration tests with Cypress, we’ll often want to stub network requests that respond ...

  4. [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 ...

  5. [Cypress] Use the Most Robust Selector for Cypress Tests

    Which selectors your choose for your tests matter, a lot. In this lesson, we'll see the recommended ...

  6. Cypress系列(0)- 如何学习 Cypress

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Cypress 未来很有可能会火的 ...

  7. Cypress系列(13)- 详细介绍 Cypress Test Runner

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Test Runner 也叫运行器 ...

  8. 【cypress】2. 安装Cypress(windows系统),以及cypress open报错解决。

    安装cypress. 一.操作系统 先确认下你的系统,是否在cypress支持范围之内: macOS 10.9 以上 (仅64-bit) Linux Ubuntu 12.04及以上版本,Fedora ...

  9. [HTML5] How Visible vs. Hidden Elements Affect Keyboard/Screen Reader Users (ARIA)

    There are many techniques for hiding content in user interfaces, and not all are created equal! Lear ...

随机推荐

  1. Sum It Up -- 深搜 ---较难

    每一行都是一组测试案例   第一个数字 表示总和 第二个数字表示 一共有几个可用数据  现在 按照从小到大的顺序   输出  那些数字中若干数字之和为总和的  信息 /. 很好很明显的  遍历痕迹 , ...

  2. CentOS 7.0 firewall防火墙关闭firewall作为防火墙,这里改为iptables防火墙

    CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤: 1.先检查是否安装了: iptables service iptables status 2.安装ip ...

  3. 简单入门构建spark1.6.1源码环境

    能有源码的辅助,加上自身的修炼,能起到很好的作用! 对于初学者,不建议,一上来看源码. 下载 http://archive.apache.org/dist/spark/spark-1.6.1/

  4. 执行update, insert,delete 语句, 不返回结果集,(类型化参数)

    /// <summary> /// 执行update, insert,delete 语句, 不返回结果集,(类型化参数) /// </summary> /// <para ...

  5. Android RecyclerView利用Glide加载大量图片into(Target)导致OOM异常

    学过android的人应该都知道Glide是一个无比强大的图片加载库,它内部已经提供了很好的缓存机制供我们选择,我们只需一个参数调用即可(DiskCacheStrategy()),而不必像Univer ...

  6. 怎么搭建Hibernate对象持久化框架?

    DBC:(Java Data Base Connectivity)java数据库连接 java.sql包提供JDBC API,可通过它编写访问数据库的程序代码.其中常用的接口和类包括下面内容: Dri ...

  7. (转)Hibernate框架基础——在Hibernate中java对象的状态

    http://blog.csdn.net/yerenyuan_pku/article/details/52760627 在Hibernate中java对象的状态 Hibernate把对象分为4种状态: ...

  8. Appium使用方法说明

    global driver# 元素定位driver.find_element_by_id("id") # id定位driver.find_element_by_name(" ...

  9. jquery制作动态添加表单行与删除表单行

    <script type="text/javascript" src="js/jquery1.7.js"></script> <s ...

  10. solaris roles cannot login directly

    oracle@solaris:~$ su - root Password: Oracle Corporation SunOS root@solaris:~# cat /etc/user_attr # ...