简体   繁体   English

在浏览器中输入文本,ruby

[英]Enter text in browser watir, ruby

I'm using watir to automate a task.我正在使用 watir 来自动执行一项任务。 After being logged in, i need to enter a text, my cursor is already on the message window so no need to locate the element, just need to type my text and send(:enter).登录后,我需要输入一个文本,我的 cursor 已经在消息 window 上,所以不需要定位元素,只需要输入我的文本并发送(:输入)。
By the way, i can not locate the input bar.顺便说一句,我找不到输入栏。

So is there a command to tell watir to enter text without locating an element?那么有没有命令告诉 watir 在不定位元素的情况下输入文本?

Yes, just use Browser#send_keys , this should work:是的,只需使用Browser#send_keys ,这应该可以:

browser.send_keys ['hello', :ENTER]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM