如何创建一个在使用 firewatir 输入启用之前处于禁用状态的文本字段?

发布于 2024-11-11 16:09:52 字数 311 浏览 5 评论 0原文

尝试设置职位名称时,“添加职位名称”按钮会隐藏,直到输入文本。使用以下代码添加职位时,禁用的按钮不会变为启用。

browser.text_field(:name, "addJobTitleValue").set firstJobTitle

引用禁用按钮的脚本 保持隐藏的实际按钮

有没有办法设置 text_field 并启用按钮?

When attempting to setup a Job Title the "add job title" buttons are hidden until text is entered. Using the following code to add a job title the disabled button does not become enabled.

browser.text_field(:name, "addJobTitleValue").set firstJobTitle

script referring to disabled button
the actual button that stays hidden

Is there a way to set the text_field and have the button become enabled?

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

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

发布评论

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

评论(2

染火枫林 2024-11-18 16:09:52

通过使用 watir-webdriver 与 firewatir,我能够使用这些代码行来启用按钮:

browser.text_field(:name, 'addJobTitleValue').clear
browser.text_field(:name, 'addJobTitleValue').fire_event 'onclick'
browser.text_field(:name, 'addJobTitleValue').send_keys firstJobTitle

这解决了我的问题,并说服我正式开始切换到 watir-webdriver。

By using the watir-webdriver versus firewatir I was able to use these lines of code to enable the button:

browser.text_field(:name, 'addJobTitleValue').clear
browser.text_field(:name, 'addJobTitleValue').fire_event 'onclick'
browser.text_field(:name, 'addJobTitleValue').send_keys firstJobTitle

This has solved the problem to me and convinced me officially to start the switch to watir-webdriver.

柠栀 2024-11-18 16:09:52

我希望使用 firewatir 的 .fire_events 之一会产生与所选答案相同的效果,并且避免切换到 watir-webdriver 的需要。

例如,

browser.text_field(:name, 'addJobTitleValue').fire_event("onclick")

用其他 JavaScript 事件替换 onclick,直到触发按钮启用。

如果没有实际的页面进行实验,我猜测 .fire_event("onchange").fire_event("onkeydown").fire_event(" onkeyup") 能够启用您想要按下的按钮。

I would expect that using one of firewatir's .fire_events would have had the same effect as the chosen answer, and avoided the need to swap over to watir-webdriver.

E.g.

browser.text_field(:name, 'addJobTitleValue').fire_event("onclick")

replacing onclick with the other javascript events, until one triggers the button to be enabled.

Without an actual page to experiment with, I'd guess at .fire_event("onchange") or .fire_event("onkeydown") or .fire_event("onkeyup") being able to enable the button you wanted to press.

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