如何选择 cypress 自动完成字段

2024-03-06

我如何在 cypress 中选择自动完成字段。

该字段如下所示:

这是 HTML 代码:

<div class="mui-select"><span style="color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;; font-size: 14px; font-weight: 600;">Select a Venue</span><div style="font-size: 16px; line-height: 24px; width: 100%; display: inline-block; position: relative; background-color: transparent; font-family: Helvetica, &quot;Open Sans&quot;; transition: height 200ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; cursor: text; border-radius: 4px; border: 1px solid rgb(255, 96, 102); margin-bottom: 36px; padding-bottom: 8px; margin-top: 8px;"><div><div style="margin-top: 0px;"></div></div><div style="display: flex; position: relative; width: 256px; padding: 0px 8px; margin: 0px; font: inherit; height: 32px; border: none; outline: none; background-color: rgba(0, 0, 0, 0); color: rgba(0, 0, 0, 0.87); cursor: initial; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); float: left; min-height: 32px; flex-wrap: nowrap;"><div style="font-size: 16px; line-height: 24px; width: 256px; height: 48px; display: inline-block; position: relative; background-color: transparent; font-family: Helvetica, &quot;Open Sans&quot;; transition: height 200ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; cursor: auto;"><input type="text" autocomplete="off" id="b0d75317-769e-4d22-aa71-8ab86304b6d5" value="" style="padding: 0px; position: relative; width: 100%; border: none; outline: none; background-color: rgba(0, 0, 0, 0); color: rgba(0, 0, 0, 0.87); cursor: inherit; font: inherit; opacity: 1; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); height: 100%;"></div><div style="display: none;"></div></div><div><hr aria-hidden="true" style="border-top: none rgb(224, 224, 224); border-left: none rgb(224, 224, 224); border-right: none rgb(224, 224, 224); border-bottom: 1px solid rgb(224, 224, 224); bottom: 8px; box-sizing: content-box; margin: 0px; position: absolute; width: 100%; display: none;"><hr aria-hidden="true" style="border-top: none rgb(244, 67, 54); border-left: none rgb(244, 67, 54); border-right: none rgb(244, 67, 54); border-bottom: 2px solid rgb(244, 67, 54); bottom: 8px; box-sizing: content-box; margin: 0px; position: absolute; width: 100%; display: none; transform: scaleX(1); transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;"></div><div style="position: absolute; bottom: -24px; font-size: 12px; line-height: 12px; color: rgb(244, 67, 54); transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; margin-top: 16px;">This field is required</div></div></div>

一种方法是通过downarrow键在type命令并使用单击命令来获取值。我已经使用“jquery”网站来测试行为;在你的测试中尝试类似的方法

it('Test to grab the autoselect values', ()=> {
    cy.visit('https://jqueryui.com/autocomplete/');
    cy.get('iframe').then(($iframe)=>{
      const $input = $iframe.contents().find('body').find('div').find('input');
      let data = cy.wrap($input)
      data.type('JavaS');
      data.type('{downarrow}');
      data.type('{downarrow}').click();
    })
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何选择 cypress 自动完成字段 的相关文章

随机推荐

  • 关于 Spirit.Qi 序列运算符和语义动作的问题

    我对灵气中的序列运算符和语义动作有一些疑问 我正在尝试为接受公制前缀 u m k M 等 以及普通指数形式的浮点数定义语法规则 rule
  • 使用 caliburn micro 设置 RadioButton 签入代码

    我在 WPF 应用程序中的向导中有一个页面 其中有 4 个单选按钮 2 组 我正在使用 Net4 和 Caliburn Micro 单击并设置值时 它会正确绑定到相应的属性 当我离开页面并返回时 我需要在代码中设置属性 并期望通过 Noti
  • NSImage 大小不是某些图片的真实大小?

    我发现有时 NSImage 大小不是真实大小 对于某些图片 而 CIImage 大小始终是真实大小 我正在用这个进行测试image http naturelap files wordpress com 2010 02 mystic natu
  • 如何在 UIImage 顶部绘制形状,同时尊重图像的 alpha 蒙版

    我需要一个可以根据标志以彩色或黑白方式绘制自身的 UIImageView BOOL isGrey 我试图通过在原始图像顶部绘制一个黑色矩形并将石英混合模式设置为颜色来实现此目的 这是可行的 只是它不尊重图像的 alpha 蒙版 见图 替代文
  • 在 Neo4j 中基于数组值创建关系

    我有两个节点代表两个人 Person name John Smith Person name Jane Doe 然后我有第三个节点 代表这两个人共同撰写的文章 Article title Some article Coauthor John
  • 升级到 Windows 10 后,Git-Bash 命令提示符无法打开

    我刚刚将操作系统升级到 Windows 10 Git Bash 甚至无法再打开 我可能需要卸载并重新安装它 但我只是想知道升级到 Windows 10 后是否还有其他人遇到过这个问题 除了卸载和重新安装之外 他们的修复方法是什么 当我的 W
  • 从表单数据填充struts2中的List

    我觉得这应该是非常明显的 但到目前为止我还没有找到答案 我想要一个字符串列表 或一个字符串数组 我真的不在乎 由 Struts2 中的表单数据填充 我看过几个关于如何做的例子bean 的索引属性 https stackoverflow co
  • XCode 7:无法将 OCUnit 转换为 XCTest

    我将 XCode 升级到 7 0 并遇到了编译问题 XCode 要求我将测试目标转换为使用 XCTest 然后我按照向导屏幕进行操作 我无法找到任何测试目标并且无法完成转换 有谁知道如何解决这一问题 Thanks 确保您已选择scheme的
  • 使用 ServiceStack 的 AsyncServiceBase 实现一劳永逸

    我有以下服务 public class AppService AsyncServiceBase
  • 通过改变窗口大小获得不同的标题大小

    我有一个 C 程序 将 TCP 标头表示为结构 include stdafx h TCP HEADER 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
  • 在 Java 中将“\\”替换为“/”

    我正在尝试更换 with 在java Android 中 这似乎不起作用 String rawPath filePath replace 这有什么问题吗 我已经转义了 并尝试转义 但没有用 原始字符串没有任何变化 filePath abc
  • Oracle 正则表达式 - 不以以下开头且不以以下结尾

    以下 Oracle 正则表达式不起作用 我不知道为什么 不以 开头abc abc 不以 结尾abc abc 问题在于 Oracle 正则表达式引擎似乎无法将 abc 字符串识别为一个单元 而只是单独查看字母 括号 应该创建一个字符串单元 所
  • SwiftUI - 动态文本的本地化

    我正在努力解决一些文本字段的本地化问题 通常 如果我要翻译的文本是硬编码的 则 Text 或 TextField 的 正常 本地化在我的应用程序中不会出现任何问题 Text English Text 我将其翻译到我的 Localized s
  • 如何在 React Native 中将一个图像放置在其他图像之上?

    我将图像放置为根节点 以便使其成为视图的背景 但似乎所有其他图像都变得不可见 有没有办法使用内置组件将图像放置在背景之上 而不需要任何插件 在下面的代码示例中landing background用作背景 我的logo图像可见 但仅当背景被移
  • 无法使用 urllib2 将内容类型设置为 application/json

    这个小宝贝 import urllib2 import simplejson as json opener urllib2 build opener opener addheaders append Content Type applica
  • NSTableView 未显示

    这是上一个问题的后续 对不起 我不知道如何添加代码或编辑 5 分钟前编写的内容 一个简短的总结 我正在尝试在常规视图上显示自定义 派生的 TableView 我没有使用IB 而是从代码中完成一切 这里的目标是构建应用程序 同时也是学习 Co
  • FileProvider 崩溃 - npe 尝试对 null 字符串调用 XmlResourceParser

    这是我的清单的一部分
  • 如何扩展现有的docker镜像?

    我在用着官方的elasticsearch Docker 镜像 https hub docker com r elasticsearch 而不是设置我自己的弹性搜索实例 这非常有效 直到我想扩展它为止 我想安装marvel http www
  • VBScript 发送键“

    我有一个 VBScript 可以取消订阅所有 Steam 创意工坊对象 Code Set WshShell WScript CreateObject WScript Shell WshShell AppActivate Steam Comm
  • 如何选择 cypress 自动完成字段

    我如何在 cypress 中选择自动完成字段 该字段如下所示 这是 HTML 代码 div class mui select span style color rgb 51 51 51 font family none font size