我在Android开发者网站上做了一些谷歌搜索和搜索,但我无法找到合适的答案.任何人都可以帮我解决这个问题吗?提前致谢.
使用如下函数创建了一个示例 Python 脚本(Elements.py):
from robot.api.deco import keyword
@keyword("join two strings")
def join_two_strings(arg1, arg2):
return arg1 + " " + arg2
Run Code Online (Sandbox Code Playgroud)
然后我将机器人框架脚本(.robot 文件)作为库导入:
*** Settings ***
Library AppiumLibrary
Library Selenium2Library
Library BuiltIn
#Here is the import of Custom Lib
Library Elements.py
*** Variable ***
*** Test Cases ***
Example that calls a Python keyword
${result}= join two strings hello world
Should be equal ${result} hello world
Run Code Online (Sandbox Code Playgroud)
在脚本上方运行后,出现“找不到名称为‘连接两个字符串’的关键字”之类的错误。即使我已经导入了自定义库。
错误信息:
[ ERROR ] Error in file C:\Users\ramana.gouda\PycharmProjects\SafeMobile\Test_Suite\TestCase_346.robot: Test library 'Elements.py' does not exist. …Run Code Online (Sandbox Code Playgroud) 使用MySQL和Robot Framework结合机器人数据库和pymysql库.
Connecting Database
Connect to database pymysql ${DB_NAME} ${DB_USER_NAME} ${DB_USER_PASSWORD} ${DB_HOST} ${DB_PORT}
Sleep ${wait_time}
Log to console Database Connection is established successfully!
Run Code Online (Sandbox Code Playgroud)
并且能够获取DB表数据并打印在IDE控制台上.问题是无法将查询结果分配给机器人变量以输入应用程序内的编辑文本.
${queryResult1} QUERY SELECT COLUMN1 FROM ${TABLE_NAME};
${query_results} Selenium2Library.Get Text ${queryResult1}
Log to Console ${query_results}
Run Code Online (Sandbox Code Playgroud)
应用脚本
Sleep 5s
Selenium2Library.Input Text ${username} ${query_results}}
Sleep 5s
Selenium2Library.Input Text ${password} ${query_results}}
Sleep 5s
Selenium2Library.Click element ${login_button}
Run Code Online (Sandbox Code Playgroud)