AutoRpa/rpa_yisaiqi/studio/codes/modules/readme.txt

86 lines
2.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 更多示例代码 http://support.i-search.com.cn:8088/showdoc/web/#/page/11923
## 导入资源库
'''
from iresource import iSResource
is_resource: iSResource = iSResource(__file__)
或者手动指定其他工程元素库文件(当前项目或其他项目)
ElementFile = r"~/NewProject1/codes/modules/resources/elements.json"
is_resource: iSResource = iSResource(json_file=ElementFile)
'''
## 全部资源
'''
all_resource = is_resource.all()
'''
## 获取全局变量、流程变量(参数)
'''
gv1 = is_resource.get_global_var("gv_1")
lv1 = is_resource.get_flow_var("lv_1")
'''
## 设置全局变量、流程变量(参数)
'''
gv1 = is_resource.set_global_var("gv_1", "gv_1新值")
lv1 = is_resource.set_flow_var("lv_1", "lv_1新值")
'''
## 获取元素对象(这段代码可从【元素库】中右击元素,点击【复制代码】直接获得)
'''
element1 = is_resource.get_element("元素ID")
element1.show() # 打印显示元素信息
all_element = is_resource.elements() # 全部元素
'''
## 支持 By.ID,By.CODE,By.NAME 获取元素对象
'''
is_resource.get_element(By.ID, "元素ID")
is_resource.get_element(By.CODE, "元素Code")
is_resource.get_element(By.NAME, "元素Name")
## 也支持具体方法获取元素对象
'''
is_resource.get_element_by_id("元素id")
is_resource.get_element_by_id("元素Code")
is_resource.get_element_by_id("元素Name")
'''
## 元素对象的 方法 和 属性
'''
element1.actions() # 所有方法
element1.properties() # 所有属性
element1.path # 元素路径
element1.snapshot # 元素快照
element1.help("click") # 查看方法使用文档
element1.click(wait_seconds=5)
is_resource.set_action_wait_seconds(5) # 全局调整动作方法执行的等待时间秒数
element1.set_text(value="测试一下")
'''
## 对象化使用
'''
# 使用对象库,通过iSObject对象可以调用子对象(如:键盘、窗口、Excel等)
iSObject.Keyboard(element1.window_title).keypress_input("abc") # 模拟按键
iSObject.Server().set_var("abc", "123") # 设置服务器变量
'''