Timeouts and delays#
Three settings control how long the driver waits. The command response timeout is how long it waits for the app to answer each command. The implicit timeout replaces the default timeout of the wait commands. The delay after command is a pause after each command, to give the app time to react. They are all methods of AltDriver.
Each command shows its signature and an example in every language; pick a language in any tab and the others switch with it.
Commands on this page#
Command |
What it does |
|---|---|
Sets how many seconds the driver waits for the app to answer a command before it raises |
|
Returns the pause, in seconds, that the driver makes after each command. |
|
Makes the driver pause for |
|
Sets the timeout, in seconds, that the wait commands use when you don’t give them one: WaitForObject, WaitForObjectWhichContains, WaitForObjectNotBePresent, WaitForCurrentSceneToBe, and the AltObject commands WaitForComponentProperty and WaitForVisualElementProperty. |
|
Returns the implicit timeout set with SetImplicitTimeout, or -1 if none is set. |
SetCommandResponseTimeout#
Sets how many seconds the driver waits for the app to answer a command before it raises CommandResponseTimeoutException. The default is 60 seconds.
void SetCommandResponseTimeout(int commandTimeout)
Example
// Give a slow app up to two minutes to answer each command.
altDriver.SetCommandResponseTimeout(120);
void setCommandResponseTimeout(int timeout)
Example
// Give a slow app up to two minutes to answer each command.
altDriver.setCommandResponseTimeout(120);
alt_driver.set_command_response_timeout(timeout)
Example
# Give a slow app up to two minutes to answer each command.
alt_driver.set_command_response_timeout(120)
Set Command Response Timeout timeout
Example
# Give a slow app up to two minutes to answer each command.
Set Command Response Timeout ${120}
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
C#, Java: |
required |
Seconds to wait for the answer to each command. |
Returns
Nothing.
Note
Python and Robot Framework can read the current value with get_command_response_timeout() and Get Command Response Timeout. C# and Java have no way to read it.
In Robot Framework, pass a number, such as ${120}. A plain 120 reaches the driver as text, and the next command fails.
See also: SetImplicitTimeout
GetDelayAfterCommand#
Returns the pause, in seconds, that the driver makes after each command. It is 0 unless you set it with SetDelayAfterCommand.
float GetDelayAfterCommand()
Example
// Pause half a second after each command during an animated menu, then go back.
float previousDelay = altDriver.GetDelayAfterCommand();
altDriver.SetDelayAfterCommand(0.5f);
altDriver.FindObject(By.NAME, "OpenMenu").Tap();
altDriver.SetDelayAfterCommand(previousDelay);
double getDelayAfterCommand()
Example
// Pause half a second after each command during an animated menu, then go back.
double previousDelay = altDriver.getDelayAfterCommand();
altDriver.setDelayAfterCommand(0.5);
altDriver.findObject(new AltFindObjectsParams.Builder(AltDriver.By.NAME, "OpenMenu")
.build()).tap();
altDriver.setDelayAfterCommand(previousDelay);
alt_driver.get_delay_after_command()
Example
from alttester import By
# Pause half a second after each command during an animated menu, then go back.
previous_delay = alt_driver.get_delay_after_command()
alt_driver.set_delay_after_command(0.5)
alt_driver.find_object(By.NAME, "OpenMenu").tap()
alt_driver.set_delay_after_command(previous_delay)
${delay}= Get Delay After Command
Example
# Pause half a second after each command during an animated menu, then go back.
${previous_delay}= Get Delay After Command
Set Delay After Command ${0.5}
${menu}= Find Object NAME OpenMenu
Tap Object ${menu}
Set Delay After Command ${previous_delay}
Returns
float (C#, Python, Robot), double (Java): The delay after each command, in seconds.
See also: SetDelayAfterCommand
SetDelayAfterCommand#
Makes the driver pause for delay seconds after each command, to give the app time to react, for example to finish an animation. The default is 0, no pause.
void SetDelayAfterCommand(float delay)
Example
// Pause half a second after each command during an animated menu, then go back.
float previousDelay = altDriver.GetDelayAfterCommand();
altDriver.SetDelayAfterCommand(0.5f);
altDriver.FindObject(By.NAME, "OpenMenu").Tap();
altDriver.SetDelayAfterCommand(previousDelay);
void setDelayAfterCommand(double delay)
Example
// Pause half a second after each command during an animated menu, then go back.
double previousDelay = altDriver.getDelayAfterCommand();
altDriver.setDelayAfterCommand(0.5);
altDriver.findObject(new AltFindObjectsParams.Builder(AltDriver.By.NAME, "OpenMenu")
.build()).tap();
altDriver.setDelayAfterCommand(previousDelay);
alt_driver.set_delay_after_command(delay)
Example
from alttester import By
# Pause half a second after each command during an animated menu, then go back.
previous_delay = alt_driver.get_delay_after_command()
alt_driver.set_delay_after_command(0.5)
alt_driver.find_object(By.NAME, "OpenMenu").tap()
alt_driver.set_delay_after_command(previous_delay)
Set Delay After Command delay
Example
# Pause half a second after each command during an animated menu, then go back.
${previous_delay}= Get Delay After Command
Set Delay After Command ${0.5}
${menu}= Find Object NAME OpenMenu
Tap Object ${menu}
Set Delay After Command ${previous_delay}
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
C#: |
required |
Seconds to pause after each command. 0 turns the pause off. |
Returns
Nothing.
Note
In Robot Framework, pass a number, such as ${0.5}. A plain 0.5 reaches the driver as text.
See also: GetDelayAfterCommand
SetImplicitTimeout#
Sets the timeout, in seconds, that the wait commands use when you don’t give them one: WaitForObject, WaitForObjectWhichContains, WaitForObjectNotBePresent, WaitForCurrentSceneToBe, and the AltObject commands WaitForComponentProperty and WaitForVisualElementProperty.
void SetImplicitTimeout(float value)
Example
// Let every wait run for up to 30 seconds unless it gives its own timeout.
altDriver.SetImplicitTimeout(30);
float timeout = altDriver.GetImplicitTimeout(); // 30
var startButton = altDriver.WaitForObject(By.NAME, "StartButton");
void setImplicitTimeout(double timeout)
Example
// Let every wait run for up to 30 seconds unless it gives its own timeout.
altDriver.setImplicitTimeout(30);
double timeout = altDriver.getImplicitTimeout(); // 30.0
AltFindObjectsParams startButtonParams =
new AltFindObjectsParams.Builder(AltDriver.By.NAME, "StartButton").build();
AltObject startButton = altDriver.waitForObject(
new AltWaitForObjectsParams.Builder(startButtonParams).build());
alt_driver.set_implicit_timeout(timeout)
Example
from alttester import By
# Let every wait run for up to 30 seconds unless it gives its own timeout.
alt_driver.set_implicit_timeout(30)
timeout = alt_driver.get_implicit_timeout() # 30
start_button = alt_driver.wait_for_object(By.NAME, "StartButton")
Set Implicit Timeout timeout
Example
# Let every wait run for up to 30 seconds unless it gives its own timeout.
Set Implicit Timeout ${30}
${timeout}= Get Implicit Timeout
${start_button}= Wait For Object NAME StartButton
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
C#: |
required |
The timeout in seconds. A negative value is rejected: C# throws |
Returns
Nothing.
Note
A wait command uses the implicit timeout whenever its own timeout is 20 seconds, its default, even when you pass 20 yourself. Give any other value to override it for one wait.
In Robot Framework, Wait For Current Scene To Be has a default timeout of 30 seconds, so the implicit timeout doesn’t apply to it.
In Robot Framework, pass a number, such as ${30}. A plain 30 reaches the driver as text.
See also: GetImplicitTimeout · SetCommandResponseTimeout
GetImplicitTimeout#
Returns the implicit timeout set with SetImplicitTimeout, or -1 if none is set.
float GetImplicitTimeout()
Example
// Let every wait run for up to 30 seconds unless it gives its own timeout.
altDriver.SetImplicitTimeout(30);
float timeout = altDriver.GetImplicitTimeout(); // 30
var startButton = altDriver.WaitForObject(By.NAME, "StartButton");
double getImplicitTimeout()
Example
// Let every wait run for up to 30 seconds unless it gives its own timeout.
altDriver.setImplicitTimeout(30);
double timeout = altDriver.getImplicitTimeout(); // 30.0
AltFindObjectsParams startButtonParams =
new AltFindObjectsParams.Builder(AltDriver.By.NAME, "StartButton").build();
AltObject startButton = altDriver.waitForObject(
new AltWaitForObjectsParams.Builder(startButtonParams).build());
alt_driver.get_implicit_timeout()
Example
from alttester import By
# Let every wait run for up to 30 seconds unless it gives its own timeout.
alt_driver.set_implicit_timeout(30)
timeout = alt_driver.get_implicit_timeout() # 30
start_button = alt_driver.wait_for_object(By.NAME, "StartButton")
${timeout}= Get Implicit Timeout
Example
# Let every wait run for up to 30 seconds unless it gives its own timeout.
Set Implicit Timeout ${30}
${timeout}= Get Implicit Timeout
${start_button}= Wait For Object NAME StartButton
Returns
float (C#, Python, Robot), double (Java): The implicit timeout in seconds, or -1 when none is set and each wait command uses its own timeout.
See also: SetImplicitTimeout