I have a doubt and I need help since I am a beginner at using Ranorex Studio.
So in the Samples folder I am using the KeePassTest sample.
But I want to do an automated test where the mouse clicks on the password input textfield in the main app window, then starts putting some handmade passwords written in an external xml file in my computer,
and IF, the password is wrong (message dialog comes on where it says the password is wrong) then the mouse clicks again on the input textfield and puts the following password after that. And so on until it finds the password "rx" then it access to another window, finally clicks on the "file tab" and then on the "exit" menuitem.
app closes, and automation test is ended.
In my recording I just opened the application, the click on the textfield, put text inside (xml is named "passwords" and is already binded correctly to my recording variable), then click "OK" button, then File tab, then exit menuitem.
Here is my Code Module (which I use to custom my personal recoerding behavior thorugh C#):
Code: Select all
/*
* Created by Ranorex
* User: mpimienta
* Date: 7/12/2014
* Time: 11:04 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
namespace KeePassTest
{
/// <summary>
/// Description of ToolbarButtons.
/// </summary>
[TestModule("DFB6335C-EFD9-4E92-BE6A-1E7373723CF4", ModuleType.UserCode, 1)]
public class ToolbarButtons : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public ToolbarButtons()
{
// Do not delete - a parameterless constructor is required!
}
/// <summary>
/// Performs the playback of actions in this module.
/// </summary>
/// <remarks>You should not call this method directly, instead pass the module
/// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
//start here
Report.Log(ReportLevel.Info, "Application", "Run application 'C:\\Program Files (x86)\\Ranorex 5.1\\Samples\\KeePassSample\\C#\\KeePassTestSuite\\KeePass\\KeePass.exe' with arguments '' in normal mode.", new RecordItemIndex(0));
Host.Local.RunApplication("C:\\Program Files (x86)\\Ranorex 5.1\\Samples\\KeePassSample\\C#\\KeePassTestSuite\\KeePass\\KeePass.exe", "", "C:\\Program Files (x86)\\Ranorex 5.1\\Samples\\KeePassSample\\C#\\KeePassTestSuite\\KeePass", false);
Delay.Milliseconds(0);
//start here
var repo = KeePassTestRepository.Instance;
var mBtnOK = repo.KeyPromptForm.MBtnOK;
var text = repo.KeyPromptForm.Text;
//Here I want to know how to make a loop so
//the machine displaces through my excel list of paswords
//and keep trying new paswords to access the program
text.TextValue = "rx" ;
mBtnOK.Click();
//file -> exit. app closes
MenuItem file = "/form[@controlname='MainForm']/?/?/menuitem[@accessiblename='File']";
file.Click();
MenuItem exit = "/form[@controlname='MainForm']/?/?/menuitem[@accessiblename='File']/menuitem[@accessiblename='Exit']";
exit.Click();
}
}
}