使用 Watir Ruby 库启动按钮单击操作
Watir::Browser.default = "firefox"
ie = Watir::Browser.start("http://cars.com")
ie.select_list(:id, 'make_1').set('Chevrolet')
ie.select_list(:id, 'model_1').set('Cobalt')
ie.select_list(:id, 'pricehighnew').set('No Max')
ie.select_list(:id, 'rdnew').set('30 miles')
ie.text_field(:name, "zc").set "44109"
ie.form(:method, "GET").submit #Here is the problem...
任何人都可以帮助我启动按钮单击操作在左上角搜索“新车”表单。看起来他们也在使用 JavaScript。我很感激任何帮助。
Watir::Browser.default = "firefox"
ie = Watir::Browser.start("http://cars.com")
ie.select_list(:id, 'make_1').set('Chevrolet')
ie.select_list(:id, 'model_1').set('Cobalt')
ie.select_list(:id, 'pricehighnew').set('No Max')
ie.select_list(:id, 'rdnew').set('30 miles')
ie.text_field(:name, "zc").set "44109"
ie.form(:method, "GET").submit #Here is the problem...
URL: http://www.cars.com/
Can anyone help me initiate button click action searching for "New Cars" form on the top left. Seems like they are using JavaScript as well. I appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能有一种方法可以使用 JavaScript 来完成此操作,但只花了一分钟,我就可以通过两种不同的方式单击按钮:
ie.span(:text=>"Search New").click
ie.link(:href=> ;"javascript:checkZipFirst(document.newForm, fastSubmitNew, document.newForm.zc.value);").click
There's probably a way to do it with JavaScript, but taking just a minute I was able to click the button two different ways:
ie.span(:text=>"Search New").click
ie.link(:href=>"javascript:checkZipFirst(document.newForm, quickSubmitNew, document.newForm.zc.value);").click
其中任何一个都可以工作:
or
or
其中 n 是索引号
Also any of these would work:
or
or
where n is the index number