Watir webdriver和extjs查找元素 [英] Watir webdriver and extjs finding element

查看:145
本文介绍了Watir webdriver和extjs查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用watir-webdriver使用ruby
进行验收测试我想问,watir webdriver是否支持ExtJs?
我试图找到由ExtJS动态生成的元素。我正在尝试像

  @browser = Watir :: Browser.new:chrome 
#一步一步到
@cbo = @ browser.execute_script返回Ext.getCmp('cboCategory')

但它没有工作
请给我一些建议。
谢谢。

解决方案

ExtJS页面很难测试,特别是查找元素。



以下是我认为有用的一些提示:





我对此主题的其他回答:




I am doing an acceptance test using watir-webdriver using ruby I wanna ask if watir webdriver is support for ExtJs or not? I am trying to find element that generated dynamically by ExtJS. I am trying doing some thing like

@browser = Watir::Browser.new :chrome
#Some step go to page
@cbo = @browser.execute_script "return Ext.getCmp('cboCategory')"

but It didn't work Please give me some advises. Thank you.

解决方案

ExtJS pages are hard to test, especially on finding elements.

Here are some of the tips I consider useful:

  • Don't ever use dynamically generated IDs. like (:id, 'ext-gen1302')
  • Don't ever use absolute/meaningless XPath, like //div[4]/div[3]/div[4]/div/div/div/span[2]/span

  • Take advantage of meaningful auto-generated partial ids and class names.

    For example, this ExtJS grid example: (:css, '.x-grid-view .x-grid-table') would be handy. If there are multiple of grids, try index them or locate the identifiable ancestor, like (:css, '#something-meaningful .x-grid-view .x-grid-table').

  • Create meaningful class names in the source code. ExtJS provides cls and tdCls for custom class names, so you can add cls:'testing-cmb-category' in your source code, and get it by (:css, '.x-panel .testing-cmb-category').

Other answers I made on this topic:

这篇关于Watir webdriver和extjs查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆