C#与Ranorex自动化公用方法
利用c#在Ranorex上写自动化已经有很长的一段时间了,总结发现常用的方法不外乎如下几种:
1、打开浏览器;或者app
public static void openBrowserMax(){
Report.Log(ReportLevel.Info, "Website", "Opening web site 'https://www.baidu.com' with browser 'IE' in normal mode.", new RecordItemIndex());
Host.Local.OpenBrowser("https://www.baidu.com", "Chrome", "", true, true, false, false, false);
Delay.Milliseconds();
}
2、删除以前的值,输入一个值;
//输入框中内容先删除后填写
public static void deleteAndInput(Ranorex.Adapter adapter, string item, Ranorex.Core.Repository.RepoItemInfo report)
{ Report.Log(ReportLevel.Info, "清空并输入", "在"+"【"+report+"】"+"处删除原有数据,并输入:【"+item+"】。");
adapter.Click();
//while(!adapter.Element.HasFocus) {adapter.Click("0;0"); adapter.Focus(); };
Keyboard.Press(System.Windows.Forms.Keys.End | System.Windows.Forms.Keys.Shift, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, , true);
Keyboard.Press(System.Windows.Forms.Keys.Delete, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, , true);
adapter.PressKeys(item);
Delay.Milliseconds(); // if(adapter.Element.GetAttributeValueText("Value")==item || adapter.Element.GetAttributeValueText("Text")==item || adapter.Element.GetAttributeValueText("InnerText")==item)
// {
// break;
// } }
3、 下拉列表框中选择或者输入一个值
//输入内容
public static void selectItem(Ranorex.Adapter adapter, string item, Ranorex.Core.Repository.RepoItemInfo report)
{
Report.Log(ReportLevel.Info, "选择下拉选项", "在"+"【"+report+"】"+"处选择"+"【"+item+"】"+"。");
if (!string.IsNullOrEmpty(item)) {
adapter.Focus();
adapter.PressKeys(item);//输入数据 Delay.Duration(, false);
}
} //输入某一选项
public static void selectList(Ranorex.Adapter adapter,string value, int length)
{
//IList<LiTag> li = repo.NewFolder.销售机会新建.ComboboxDropdown.FindDescendants<LiTag>(); //找到控件adapter的LiTag后代
IList<LiTag> li = adapter.FindDescendants<LiTag>();
foreach(LiTag l in li)
{
string text = l.InnerText;
if(text.Length>=)
{
Report.Log(ReportLevel.Info,text);
string text1 = text.Substring(,length);
if(value==text1)
{
l.Click(); //也可以换成l.selected = true; 如果有selected这个属性的话
break;
}
}
}
}
4、通过按Down按钮或则Up来再下拉列表框中选择一个值
Keyboard.Press("{Down 7}{Up 4}{Enter}");
5、点击一个按钮
adapter1.Click();
6、点击按钮直到某个控件出现为止
//等待30s知道某个控件出现
public static void waitfor30sReportExist(Ranorex.Adapter adapter1, Ranorex.Core.Repository.RepoItemInfo adapter2Info){
int count = ;
Report.Log(ReportLevel.Info,"双击"+adapter1.ToString()+",等待"+adapter2Info.ToString()+"出现");
while(!adapter2Info.Exists()){
adapter1.Click();
Delay.Milliseconds(,false);
count = count + ;
if(count >= )
{
Report.Log(ReportLevel.Failure,"在30s内没有找到控件"+adapter2Info.ToString());
break;
} }
}
7、通过xpath来找到某个控件(或判断某个控件是否存在)
Element element = Element.FromPath("/dom[@caption='******' and @page='quotation_search.html']//table[#'resultTable']/tbody/tr");
RxPath xpa = new RxPath("/dom[@caption='*****' and @page='quotation_search.html']//table[#'resultTable']/tbody/tr");
IList<Element> ils= element.Find(xpa);
Report.Info("ils.count:" + ils.Count);
8、通过坐标来点击控件
Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item '导航按钮' at 35;131.", repo.导航按钮Info, new RecordItemIndex());
repo.导航按钮.Click("35;131");
Delay.Milliseconds();
C#与Ranorex自动化公用方法的更多相关文章
- DbHelperSQL 判断数据库表结构公用方法
#region 公用方法 /// <summary> /// 判断是否存在某表的某个字段 /// </summary> ...
- util包就是用来放一些公用方法和数据结构的
util包就是用来放一些公用方法和数据结构的
- Python项目开发公用方法--excel生成方法
在实际开发中,我们有时会遇到数据导出的需求.一般的,导出的文件格式为Excel形式. 那么,excel的生成就适合抽离出一个独立的公用方法来实现: def generate_excel(excel_n ...
- axios源码入口以及公用方法
axios学习笔记(公用方法) 源码地址 找到入口文件 axios/lib/axios.js var utils = require('./utils'); var bind = require('. ...
- Objective-C运行时编程 - 实现自动化description方法的思路及代码示例
发布自米高 | Michael - 博客园,源地址:http://www.cnblogs.com/michaellfx/p/4232205.html,转载请注明. 本文结构 基础实现 性能优化 参考 ...
- jsonpath读取json数据格式公用方法!!!
import java.util.LinkedHashMap; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Pred ...
- 「小程序JAVA实战」 小程序抽离公用方法进行模块化(12)
转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-12/ 小程序的模块化,把砖磊成一个墩子,用的时候把整个墩子移走.js更好的调用,应用更加公用化.源 ...
- Android App性能自动化评测方法
前言 App运行在设备上的性能表现也是质量保障的一个重要环节.因此,当我们确保了基本功能的准确之后,还需要有一定的方法评测App在不同设备上的性能表现.本文将从性能指标,评测方法,自动化体系建设等三个 ...
- Web自动化定位方法以及常用便捷操作
很遗憾现在才开始给大家逐步分享自动化教程,原本计划着将现有的接口以及app.pc网页端进行自动化处理后再逐步给大家好好分享一下,由于当前实在没必要自动化操作了,所以临时用脑海中的知识再为大家继续更一篇 ...
随机推荐
- Codeforces Round #319 (Div. 2)
水 A - Multiplication Table 不要想复杂,第一题就是纯暴力 代码: #include <cstdio> #include <algorithm> #in ...
- Mysql的外键
概念:如果一个实体A的某一字段,刚好指向或引用另一个实体B的主键,那么实体A的这个字段就叫作外键,所以简单来说,外键就是外面的主键,就是其他表的主键. 例: 以上的学生表的班级字段,就是一个外键! 其 ...
- rac 添加 资源
10g : 自动化.监控.os,存储,底成,网络,规范
- PV,UV,IP概念
PV是网站分析的一个术语,用以衡量网站用户访问的网页的数量.对于广告主,PV值可预期它可以带来多少广告收入.一般来说,PV与来访者的数量成正比,但是PV并不直接决定页面的真实来访者数量,如同一个来访者 ...
- 【ADO.NET】 使用通用数据库操作类Database (SQL Server)
一.Web.config配置 <connectionStrings> <add name="constr_name" connectionString=" ...
- JSP报错The value for the useBean class attribute *** is invalid.
环境:IDEA+Tomcat9+JDK1.8 在前期学习时,环境一直能够"正常"使用,实际上环境并没有完全搭建成功. 推荐: https://blog.csdn.net/lw_po ...
- 写给技术lead的招聘指南
工作这么久,面试过的工程师不下两三百人.大部份招到的人都比靠谱当然也有失败的例子.把亲身经历总结如下: 1. 什么人一定不能招: 理解能力差: 对你提出的问题,答不对题,重复提问.面试官可以在面试当中 ...
- Struts2控制文件的上传与下载
Struts2控制文件上传与下载的几个注意事项: (1)必须将表单的method设置为post,将enctype设置为multipart/from-data.只有这样,浏览器才会把用户选择文件的二进制 ...
- Hadoop 安装过程中出现的问题
1.hadoop-daemon.sh start namenode 启动失败 查看hadoop/logs 下面的日志 出现 2017-04-11 15:35:13,860 WARN org.apach ...
- ElasticSearch数据库同步插件logstash
1.下载和elasticsearch 相同版本的logstash. 2.进行解压后,进入bin下,新建一个文件mysql.conf,并输入 input { stdin{ }} output { std ...