You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ranorex中从SQL数据库获取用户名和密码?自动化测试新手咨询

Ranorex iOS/Android Automation: SQL Data vs. Variables for Login Scenarios

Hey there! Let's walk through your questions since you're just getting started with Ranorex and mobile test automation—great choice picking up this tool for cross-platform testing.

Is Fetching Login Data From SQL Reasonable?

Absolutely, but it depends on your test scale and data needs. Let's break it down:

  • When it makes sense:
    • You need multiple sets of test data (e.g., 5+ valid user accounts, various invalid cases like empty fields, wrong passwords, malformed usernames)
    • Your test data needs to stay in sync with other systems (e.g., your app's user database)
    • You want to centralize and maintain test data across multiple test cases or teams
  • When variables are simpler:
    • You only have 1-2 sets of static test data (e.g., one valid login, one invalid login)
    • You're just prototyping your test workflow and don't want to set up a database connection yet

For your two specific scenarios (VALID-LOGIN-data and INVALID-LOGIN-data), both approaches work—but SQL will scale way better if you ever need to add more test cases later.

How to Retrieve Username/Password From SQL in Ranorex

Here's a step-by-step guide tailored to mobile login tests:

  1. Add a Database Data Source
    • Open your Ranorex Test Suite, right-click on Data Sources > Add > Database Connection
    • Fill in your SQL server details (server name, authentication type, database name) and click Test Connection to confirm it works
  2. Write Targeted Queries for Your Scenarios
    • For valid login data, use a query like:
      SELECT username, password FROM login_test_data WHERE test_scenario = 'VALID-LOGIN-data'
      
    • For invalid login data, adjust the query to:
      SELECT username, password FROM login_test_data WHERE test_scenario = 'INVALID-LOGIN-data'
      
    (Pro tip: Add a test_scenario column to your SQL table to easily filter between valid/invalid cases)
  3. Bind Data to Your Login Actions
    • Open your recorded login test case. Select the "Enter Username" action, go to the Data Binding tab in the properties panel
    • Choose your database data source, then map the username column to the input value. Repeat this for the password field
  4. Loop Through Multiple Data Rows
    • If you have multiple valid/invalid entries, right-click your test case > Properties > Under Data Source, select your SQL data source. Ranorex will automatically run the test for every row in your query results

Database vs. Variables: Which to Use for Your Scenarios?

Let's match each scenario to the best approach:

  • VALID-LOGIN-data:
    • Use variables if you only need to test one valid account (quick to set up: create ValidUsername and ValidPassword test variables, bind them to your input fields)
    • Use SQL if you need to test multiple valid accounts (e.g., admin user, regular user, restricted user) or if the valid accounts change frequently
  • INVALID-LOGIN-data:
    • Variables work for a single invalid case, but SQL is way better here—you can store all invalid edge cases (empty username, wrong password, too-short password, etc.) in one table and run them all in a single test suite execution without modifying your test code

Final Recommendation for Beginners

Start with variables to get your login test up and running quickly—this helps you learn Ranorex's core features without getting bogged down in database setup. Once you're comfortable, migrate to SQL as you add more test cases or need to manage larger sets of test data.

内容的提问来源于stack exchange,提问作者Ghasem Tabatabaei

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 21:22:31