Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323765

Summary: WithLabel-matchers are not scoped to the ControlFinder, they do a shell-wide search instead
Product: [Technology] SWTBot Reporter: Ralf Ebert <ralf>
Component: SWTBotAssignee: Project Inbox <swtbot-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: KetanPadegaonkar: iplog+
Version: 2.0.0-dev   
Target Milestone: 2.0.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
0001-SWTBotViewTest-viewBotWidgetScope-reproduces-Bug-323.patch
none
0001-SWTBotViewTest-viewBotWidgetScope-reproduces-Bug-323.patch
none
0002-323765-WithLabel-matchers-are-not-scoped-to-the-Cont.patch none

Description Ralf Ebert CLA 2010-08-26 18:53:42 EDT
Build Identifier: 

When searching for controls restricted to views or editors like bot.viewById("...").bot().textWithLabel("...") the WithLabel matcher will leave the parent Composite and return controls from other views.

Reproducible: Always

Steps to Reproduce:
See attached test case SWTBotViewTest#viewBotWidgetScope
Comment 1 Ralf Ebert CLA 2010-08-26 18:57:01 EDT
Created attachment 177571 [details]
0001-SWTBotViewTest-viewBotWidgetScope-reproduces-Bug-323.patch
Comment 2 Ralf Ebert CLA 2010-08-27 06:29:29 EDT
This happens because org.eclipse.swtbot.swt.finder.matchers.WithLabel does a shell-wide search if it is not instantiated with a parent. Expressing scope by parent and not by a Finder object seems bogus to me and this way of instantiating the matcher seems to be used. My current plan to fix this is to allow matchers (in general) to get the control finder they are used for by implementing an interface like IControlFinderAware#setControlFinder().
Comment 3 Ralf Ebert CLA 2010-08-27 08:22:51 EDT
Created attachment 177610 [details]
0001-SWTBotViewTest-viewBotWidgetScope-reproduces-Bug-323.patch
Comment 4 Ralf Ebert CLA 2010-08-27 08:23:37 EDT
Created attachment 177611 [details]
0002-323765-WithLabel-matchers-are-not-scoped-to-the-Cont.patch

From: Ralf Ebert <ralf@ralfebert.de>
Date: Fri, 27 Aug 2010 14:21:32 +0200
Subject: [PATCH 2/2] 323765: WithLabel-matchers are not scoped to the ControlFinder

WithLabel finds controls using the ControlFinder now, so it is correctly
restricted when used for scoped bots like viewById("...").bot(). For this,
the SWTBot class is generated with an withLabel() method which passes in
its ControlFinder.
Comment 5 Ralf Ebert CLA 2010-09-06 21:58:42 EDT
May I kindly ask to review the patches and give me feedback if there is anything left to do about them?
Comment 6 Ketan Padegaonkar CLA 2010-10-12 11:55:08 EDT
Applied patch, sorry that it took a long time to resolve. Please verify and mark as fixed.