查找和输入Capybara的文字

发布于 2025-01-21 15:47:55 字数 534 浏览 0 评论 0原文

我目前正在尝试找到这本特定的教科书并将钥匙发送给它。我遇到的问题是我正在尝试使用查找方法。我在此文本框上尝试了很多变体,但找不到本教科书。

HTML标签:

<div class="selectize-input items not-full ng-valid has-options ng-dirty"><input type="text" autocomplete="off" tabindex="0" style="width: 187.033px; opacity: 1; position: relative; left: 0px;" placeholder="Type a Catname or Kob name"></div>

这是我要做的事情,

find('selectize-input items not-full ng-valid has-options').sendkeys 'Meow'

如果可能的话,可以轻松地执行此操作。我还将如何通过发送键输入。

I'm currently trying to find this specific textbook and send keys to it. The problem that I'm having is I'm trying to use the find method. I tried a lot of variations on this textbox and was unable to find this textbook.

HTML TAG:

<div class="selectize-input items not-full ng-valid has-options ng-dirty"><input type="text" autocomplete="off" tabindex="0" style="width: 187.033px; opacity: 1; position: relative; left: 0px;" placeholder="Type a Catname or Kob name"></div>

Here's what I'm trying to do

find('selectize-input items not-full ng-valid has-options').sendkeys 'Meow'

Would there be an easy of doing this without using xpath if possible. Also how would I enter via send keys.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

完美的未来在梦里 2025-01-28 15:47:55

fill_in使用Capybaras:Fillable_field选择器,通过ID,名称,占位符或相关标签文本找到元素。因此,输入该领域文本的最简单方法就是除了

fill_in('Type a Catname or Kob name', with: 'Meow')

此外要做,您最近发布了许多问题,在这些问题中您要混合CSS选择器。我认为您真的会从中使用 https://flukeout.github.io/ 学习和了解CSS选择器。您正在混合元素类型选择器,类选择器等。如果您真的想通过父元素的类名来完成,则可以做类似的操作,

find('.selectize-input.items.not-full.ng-valid.has-options.ng-dirty input').send_keys('Meow')

但这确实是一种可怕的,脆弱的方法。在CSS选择器中注意在班级名称前,父和后代选择器之间的空间,no 在元素类型选择器的前面等等。

fill_in uses Capybaras :fillable_field selector which finds elements by id, name, placeholder, or associated label text. Therfore the easiest way of entering text in that field is to just do

fill_in('Type a Catname or Kob name', with: 'Meow')

Beyond that, you've recently posted a number of questions where you are mixing up CSS selectors. I think you would really benefit from using https://flukeout.github.io/ to learn and understand CSS selectors. You are mixing up element type selectors, class selectors, etc. If you really want to do it via class names of the parent element you could do something like

find('.selectize-input.items.not-full.ng-valid.has-options.ng-dirty input').send_keys('Meow')

but that's really a terrible, brittle way to do it. Notice in the CSS selector the .s in front of class names, space between parent and descendant selectors, no . in front of the element type selector, etc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文