`
longgangbai
  • 浏览: 7370499 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

SWTBot中运行中那些参数控制

阅读更多

Can I slow down the execution speed of SWTBot tests?

Yes you can! To slow down the speed of execution of SWTBot, you need to set the system property "org.eclipse.swtbot.playback.delay". This delay is in milliseconds. You can also set this property in code as follows:

// slow down tests
SWTBotPreferences.PLAYBACK_DELAY = 10;
// set to the default speed
SWTBotPreferences.PLAYBACK_DELAY = 0;

Can I change the timeout for execution of SWTBot tests?

Yes you can! To change the timeout, you need to set the system property "org.eclipse.swtbot.search.timeout". The timeout is specified in milliseconds. You can also set this property in code as follows:

// increase timeout to 10 seconds
SWTBotPreferences.TIMEOUT = 10000;
// set to the default timeout of 5 seconds
SWTBotPreferences.TIMEOUT = 5000;

Can I change the poll delay for evaluating conditions in SWTBot tests?

Yes you can! To change the poll delay, you need to set the system property "org.eclipse.swtbot.playback.poll.delay". The poll delay is specified in milliseconds. You can also set this property in code as follows:

// increase timeout to 1 second
SWTBotPreferences.DEFAULT_POLL_DELAY = 1000;
// set to the default timeout of 500ms.
SWTBotPreferences.DEFAULT_POLL_DELAY = 500;

         

在swtbot运行中总存在一些控制参数如超时时间,失败截屏数量等.具体请看下面不解释:

public interface SWTBotPreferenceConstants {

	/** @see SWTBotPreferences#DEFAULT_KEY */
	public static final String	KEY_DEFAULT_KEY					= "org.eclipse.swtbot.search.defaultKey";
	/** @see SWTBotPreferences#TIMEOUT */
	public static final String	KEY_TIMEOUT						= "org.eclipse.swtbot.search.timeout";

	/** @see SWTBotPreferences#PLAYBACK_DELAY */
	public static final String	KEY_PLAYBACK_DELAY				= "org.eclipse.swtbot.playback.delay";
	/** @see SWTBotPreferences#DEFAULT_POLL_DELAY */
	public static final String	KEY_DEFAULT_POLL_DELAY			= "org.eclipse.swtbot.playback.poll.delay";

	/** @see SWTBotPreferences#MAX_ERROR_SCREENSHOT_COUNT */
	public static final String	KEY_MAX_ERROR_SCREENSHOT_COUNT	= "org.eclipse.swtbot.screenshots.error.maxcount";
	/** @see SWTBotPreferences#SCREENSHOTS_DIR */
	public static final String	KEY_SCREENSHOTS_DIR				= "org.eclipse.swtbot.screenshots.dir";
	/** @see SWTBotPreferences#SCREENSHOT_FORMAT */
	public static final String	KEY_SCREENSHOT_FORMAT			= "org.eclipse.swtbot.screenshots.format";

	/** @see SWTBotPreferences#KEYBOARD_LAYOUT */
	public static final String	KEY_KEYBOARD_LAYOUT				= "org.eclipse.swtbot.keyboard.layout";
	/** @see SWTBotPreferences#TYPE_INTERVAL */
	public static final String	KEY_TYPE_INTERVAL				= "org.eclipse.swtbot.keyboard.interval";
	/** @see SWTBotPreferences#KEYBOARD_STRATEGY */
	public static final String	KEY_KEYBOARD_STRATEGY			= "org.eclipse.swtbot.keyboard.strategy";

}

 

	/**
	 * The default key used to match SWT widgets. Defaults to {@code org.eclipse.swtbot.widget.key}. To set another
	 * default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_DEFAULT_KEY}.
	 */
	public static String		DEFAULT_KEY					= System.getProperty(KEY_DEFAULT_KEY, "org.eclipse.swtbot.widget.key");

	/**
	 * The timeout for finding widgets among other things. Defaults to 5000ms. To set another default use the system
	 * property {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_TIMEOUT}.
	 */
	public static long			TIMEOUT						= toLong(System.getProperty(KEY_TIMEOUT, "5000"), 5000);

	/**
	 * The speed of playback in milliseconds. Defaults to 0. To set another default, use the system property {@code
	 * org.eclipse.swtbot.playback.delay}.
	 */
	public static long			PLAYBACK_DELAY				= toLong(System.getProperty(KEY_PLAYBACK_DELAY, "0"), 0);

	/**
	 * The maximum number of screenshots that SWTBot should capture. Defaults to 100. To set another default use the
	 * system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_MAX_ERROR_SCREENSHOT_COUNT}.
	 */
	public static int			MAX_ERROR_SCREENSHOT_COUNT	= toInt(System.getProperty(KEY_MAX_ERROR_SCREENSHOT_COUNT, "100"), 100);

	/**
	 * The directory in which screenshots should be generated. Defaults to "screenshots". To set another default use the
	 * system property {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_SCREENSHOTS_DIR}.
	 */
	public static String		SCREENSHOTS_DIR				= System.getProperty(KEY_SCREENSHOTS_DIR, "screenshots");

	/**
	 * The screenshot image format to be used. Defaults to "jpeg". To set another default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_SCREENSHOT_FORMAT}. The value must be
	 * one these: BMP, GIF, ICO, JPEG, JPG, PNG or TIFF.
	 */
	public static String		SCREENSHOT_FORMAT			= System.getProperty(KEY_SCREENSHOT_FORMAT, "jpeg");

	/**
	 * The keyboard layout. This value is autodetected at runtime. This can be set using the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_KEYBOARD_LAYOUT}.
	 * <p>
	 * <strong>Note:</strong> the layout must be of the form foo.bar.baz.[MAC_][LANGUAGE_][COUNTRY_][VARIANT_] This
	 * expects a file named "foo/bar/baz/[MAC_][LANGUAGE_][COUNTRY_][VARIANT_].keyboard"
	 * </p>
	 * Eg:
	 * <table border="1">
	 * <tr>
	 * <th align="left"><b>Layout Name</b></th>
	 * <th align="left"><b>Configuration File</b></th>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.MAC.EN.US</td>
	 * <td>com/foo/bar/MAC_EN_US.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.MAC.EN_GB</td>
	 * <td>com/foo/bar/MAC_EN_GB.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.FR_FR</td>
	 * <td>com/foo/bar/FR_FR.keyboard</td>
	 * </tr>
	 * <tr>
	 * <td>com.foo.bar.DE</td>
	 * <td>/com/foo/bar/DE.keyboard</td>
	 * </tr>
	 * </table>
	 *
	 * @see Locale
	 */
	public static String		KEYBOARD_LAYOUT				= System.getProperty(KEY_KEYBOARD_LAYOUT, KeyboardLayoutDetector
																	.detectKeyboard());

	/**
	 * The the time interval in milliseconds between typing characters in a string. Defaults to 50ms. To set another
	 * default use the system property {@code org.eclipse.swtbot.keyboard.interval}.
	 */
	public static int			TYPE_INTERVAL				= toInt(System.getProperty(KEY_TYPE_INTERVAL, "50"), 50);
	/**
	 * The default keyboard strategy. Defaults to org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy. To set
	 * another default use the system property {@code org.eclipse.swtbot.keyboard.strategy}. This property must be set
	 * to a subclass of {@link KeyboardStrategy}.
	 *
	 * @see KeyboardStrategy
	 * @see Keyboard
	 */
	public static String		KEYBOARD_STRATEGY			= System.getProperty(KEY_KEYBOARD_STRATEGY,
																	"org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy");

	/**
	 * The default time delay between successive polling while waiting for a condition to be evaluated. Defaults to
	 * 500ms. To set another default use the system property
	 * {@value org.eclipse.swtbot.swt.finder.utils.SWTBotPreferenceConstants#KEY_DEFAULT_POLL_DELAY}.
	 *
	 * @see SWTBot#waitUntil(ICondition, long, long)
	 * @see SWTBot#waitWhile(ICondition, long, long)
	 */
	public static final long	DEFAULT_POLL_DELAY			= toLong(System.getProperty(KEY_DEFAULT_POLL_DELAY, "500"), 500);

 

分享到:
评论

相关推荐

    swtbot运行原理

    在SWTBot的运行过程中,主要包含以下几个步骤: 1. **初始化**:测试开始前,SWTBot会加载必要的库,并初始化测试环境。这包括创建一个测试上下文,注册所需的事件监听器,并准备用于测试的对象。 2. **对象定位**...

    swtbot详细例子说明网页分享

    首先,在Eclipse中打开`Help` -&gt; `Install New Software`,然后添加SWTBot的更新站点地址,选择要安装的版本,按照向导提示完成安装。 ### 示例详解 一个简单的SWTBot测试示例可能如下: ```java import org....

    SWTBot自动化测试学习软件

    SWTBot是一款强大的开源自动化测试工具,主要用于Java GUI...在实际项目中,结合版本控制系统(如Git)、持续集成工具(如Jenkins)以及代码质量管理工具(如SonarQube),SWTBot的自动化测试能力将发挥更大的作用。

    swtbot 详细例子说明

    在"swtbotw例子"中,我们可以深入理解SWTBot的用法和功能。 首先,SWTBot提供了一种简洁的API,用于选择和操作UI元素,如按钮、文本框、菜单项等。例如,你可以使用`Bot.button()`或`Bot.menuItem()`来定位并触发...

    swtbot学习资料

    在SWTBot中,你可以使用查找机制来定位GUI元素。这可以通过Widget的属性,如标签、ID或位置来实现。例如,`bot.button("OK")` 将找到并返回一个标签为"OK"的按钮对象,然后可以调用其方法执行点击操作。 接下来,...

    SWTBot收集

    使用SWTBot,你可以编写测试脚本来模拟用户在Eclipse RCP应用中的各种操作。例如,你可以创建一个测试来打开特定的视图,点击某个按钮,检查结果是否符合预期。SWTBot提供了如`Bot.button()`、`Bot.menu()`和`Bot....

    SWTBot插件包及例子

    标题中的"SWTBot插件包"指的是一个包含SWTBot库及相关工具的集合,它为Eclipse开发环境提供了一种集成的测试解决方案。通过安装这个插件,开发者可以利用SWTBot的强大功能来自动化SWT和JFace构建的图形用户界面(GUI...

    使用SWTBOT进行GUI自动化测试

    SWTBOT的核心优势在于其能够准确识别和操作界面元素,即使这些元素在不同的运行环境中可能有所变化。 #### SWTBOT的关键特点 - **易于学习与使用**:对于熟悉Eclipse RCP的开发者来说,SWTBOT的API相对直观易懂。 -...

    swtbot eclipse插件 测试界面

    swtbot eclipse插件 测试界面

    Web页面测试-swtbot

    Web工程强调从设计、开发到测试整个生命周期的质量控制,其中,测试阶段尤其关键,它不仅要验证功能的正确性,还要评估用户体验、性能和安全性等方面。 #### 三、Web测试的特点与挑战 Web环境具有浏览器平台不兼容...

    如何为EclipseJFaceUI运行单元测试Java开发

    4. 在Eclipse中配置JUnit运行配置,指定SWTBot测试运行器。 5. 运行测试并根据结果迭代改进代码。 通过遵循这些步骤,开发者可以有效地对Eclipse JFace UI应用程序进行单元测试,确保代码的质量和稳定性。

    SWTBot - SWT/Eclipse functional testing-开源

    SWTBot是用于SWT / RCP应用程序的自动化和测试工具,具有记录和回放脚本的功能。 功能将包括基于文本的脚本,对测试套件的回放,报告和多线程回放的ant支持。

    scenarioo-e4-swtbot-example-integration

    方案示例-swtbot-e4 结合使用场景和SWTBot来测试和记录Eclipse RCP e4示例应用程序的示例UI测试和Scenarioo集成可在plugins/org.scenarioo.example.e4.test/src/org/scenarioo/example/e4文件夹中找到。构建并运行...

    eclipse4.4.4+gmf+swtbot

    NULL 博文链接:https://mwhgjava.iteye.com/blog/2257771

    SWT的详解,例子,介绍

    1. **安装和配置**:如何在已有的Eclipse环境中安装SWTBOT及其依赖,配置测试运行环境。 2. **基本概念**:了解SWTBOT的核心类,如`SWTBot`、`BotFactory`和`WidgetFinder`,以及它们在测试中的作用。 3. **选择和...

    SWT的自动化测试框架

    虽然SWTBot专为SWT和RCP应用设计,但与其他自动化测试框架如Selenium相比,它的优势在于对SWT控件的深度理解和精确控制。然而,对于Web应用或非SWT的桌面应用,Selenium等其他框架可能更合适。 总的来说,SWTBot是...

    pdi-ui-test:基于SWTBot的用于Pentaho数据集成的UI测试的集合

    【标题】"pdi-ui-test"是一个专门针对Pentaho数据集成(PDI)的UI自动化测试框架,它利用了SWTBot库来实现对PDI用户界面的全面测试。 【描述】该项目"pdi-ui-test"的核心目标是提供一个高效、可靠的测试套件,确保...

    Eclipse 4 Plug-in Development by Example: Beginner's Guide

    书中还介绍了如何与用户交互以及如何在后台执行长时间运行的任务,并提供了一些具体的代码片段作为示例。 本书深入探讨了创建和管理首选项(preferences)的细节,包括存储和获取首选项的正确方法,以及如何将它们...

Global site tag (gtag.js) - Google Analytics