没有合适的资源?快使用搜索试试~ 我知道了~
WatiN中所有的控件以及控件的识别方法
5星 · 超过95%的资源 需积分: 10 6 下载量 12 浏览量
2013-01-07
22:37:35
上传
评论
收藏 4KB TXT 举报
温馨提示
试读
2页
WatiN中所有的控件以及控件的识别方法
资源推荐
资源详情
资源评论
WatiN中所有的控件以及控件的识别方法
在WatiN的源代码中可以看到所有的控件识别设计类都是在继承了与element相关的类
包括Element, ElementAttributeBag, ElementCollection, ElementContainer, ElementSupport, ElementTag。
首先来看Element的类可以看到它继承IAttributeBag类,在Elemental类中写到的方法有:
1. Classname: Get the name of the stylesheet class assigned to this element;得到传输给此控件默认格式类的名称。返回值为string.
2. Complete: Boolean Value, Get a value indicating whether the element is completely loaded;得到一个波尔值,查看是否此对当前控件的操作完全加载。返回值为波尔值.
3. Enabled: Get a Value indicating whether this element is enabled.得到一个波尔值来确认当前的控件是否是可用的.返回值为波尔值.
4. ID: Get the if of this element as specified in the HTML ,返回当前控件在此HTML页面中的识别ID, 返回值为string。
5.TEXT: Get the inner text of this element(or all the inner text of all the elements contained in this elment). 返回当前控件中的文本,或者是返回当前控件所包含的控件中的所有文本,返回值为string.
6.TextBefore: Returns the text displayed before this element when it’s wrapped in a Label element, otherwise it returns null. 返回当前控件前面的Label的文本内容,如果当前控件前面的控件不是Label则返回null, 返回值为string.
7. InnerHtml: Gets the inner HTML of this element. 返回当前控件的内部HTML代码。返回值不用说当然为string.
8. OuterText: Gets the outer text, 返回外部文档,返回值为string.
Shit,这个控件我还真不知道怎么用,呵呵。查了一下解释如下:
InnerText:不包括标志,标志以内的纯文本
OuterText:包括标志,连标记及标志内的文本
InnerHtml:不包括标志,标志以内的Html内容
OuterHtml:包括标志,连标记及标志内的Html内容
9. TagName: Gets the tag name of this element 返回当前控件的标签。返回值为string.
10. Title: Get the title. 返回当前页面的标题。返回值为stieng.
11. NextSibling: Gets the next sibling of this element in the Dom of the HTML page.返回当前标签在此HTML页面Dom控件中的下一个兄弟控件。返回值为控件即(element)
12. PreviousSibling: Gets the previous sibling of this element in the Dom of the HTML page. 返回当前标签在此HTML页面Dom控件中的下一个兄弟控件,返回值为控件即(element)。
13. Parent: Gets the parent element of this element, If the parent type is known you can cast it to that type. 返回当前控件的父级控件,如果父级的控件类型知道,可以定义一个和父级同类型的变量控件。返回类型为控件(element).这个比较难理解,下面是举例:
Div
a id="watinlink" href="http://watin.sourceforge.net" /
a href="http://sourceforge.net/projects/watin" /
Div
上面的HTML所示第二个超链接没有id,如何点击它来实现超链接?这时可以使用Parent这个方法:
首先定义一个变量Div,然后把这两个超链接所在的div赋值给这个Division变量。
在WatiN的源代码中可以看到所有的控件识别设计类都是在继承了与element相关的类
包括Element, ElementAttributeBag, ElementCollection, ElementContainer, ElementSupport, ElementTag。
首先来看Element的类可以看到它继承IAttributeBag类,在Elemental类中写到的方法有:
1. Classname: Get the name of the stylesheet class assigned to this element;得到传输给此控件默认格式类的名称。返回值为string.
2. Complete: Boolean Value, Get a value indicating whether the element is completely loaded;得到一个波尔值,查看是否此对当前控件的操作完全加载。返回值为波尔值.
3. Enabled: Get a Value indicating whether this element is enabled.得到一个波尔值来确认当前的控件是否是可用的.返回值为波尔值.
4. ID: Get the if of this element as specified in the HTML ,返回当前控件在此HTML页面中的识别ID, 返回值为string。
5.TEXT: Get the inner text of this element(or all the inner text of all the elements contained in this elment). 返回当前控件中的文本,或者是返回当前控件所包含的控件中的所有文本,返回值为string.
6.TextBefore: Returns the text displayed before this element when it’s wrapped in a Label element, otherwise it returns null. 返回当前控件前面的Label的文本内容,如果当前控件前面的控件不是Label则返回null, 返回值为string.
7. InnerHtml: Gets the inner HTML of this element. 返回当前控件的内部HTML代码。返回值不用说当然为string.
8. OuterText: Gets the outer text, 返回外部文档,返回值为string.
Shit,这个控件我还真不知道怎么用,呵呵。查了一下解释如下:
InnerText:不包括标志,标志以内的纯文本
OuterText:包括标志,连标记及标志内的文本
InnerHtml:不包括标志,标志以内的Html内容
OuterHtml:包括标志,连标记及标志内的Html内容
9. TagName: Gets the tag name of this element 返回当前控件的标签。返回值为string.
10. Title: Get the title. 返回当前页面的标题。返回值为stieng.
11. NextSibling: Gets the next sibling of this element in the Dom of the HTML page.返回当前标签在此HTML页面Dom控件中的下一个兄弟控件。返回值为控件即(element)
12. PreviousSibling: Gets the previous sibling of this element in the Dom of the HTML page. 返回当前标签在此HTML页面Dom控件中的下一个兄弟控件,返回值为控件即(element)。
13. Parent: Gets the parent element of this element, If the parent type is known you can cast it to that type. 返回当前控件的父级控件,如果父级的控件类型知道,可以定义一个和父级同类型的变量控件。返回类型为控件(element).这个比较难理解,下面是举例:
Div
a id="watinlink" href="http://watin.sourceforge.net" /
a href="http://sourceforge.net/projects/watin" /
Div
上面的HTML所示第二个超链接没有id,如何点击它来实现超链接?这时可以使用Parent这个方法:
首先定义一个变量Div,然后把这两个超链接所在的div赋值给这个Division变量。
资源评论
- shevche242016-07-28可以用,不错
蓝色的海豚
- 粉丝: 2
- 资源: 32
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功