Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » bot().textWithLabel() does not found appropriated text field
bot().textWithLabel() does not found appropriated text field [message #1800978] Thu, 10 January 2019 14:56 Go to next message
Alex Gor is currently offline Alex GorFriend
Messages: 151
Registered: November 2014
Location: Russia
Senior Member
Hello

I observed the following problem:
A Dialog has two text fields
- one with label ABC
- one with label ABCXYZ

I would like to find text field with label ABC, but method textWithLabel("ABC")
returns the second text field with label ABCXYZ. I use SWTbot version 2.2.1

Could you help me to resolve this issue

Thank you in advance
Alex
Re: bot().textWithLabel() does not found appropriated text field [message #1800990 is a reply to message #1800978] Thu, 10 January 2019 17:12 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 75
Registered: July 2009
Member
Hi Alex,

The (widget)WithLabel() methods are helpers in SWTBot that find a widget based on the text of the preceding Label in the Composite. It's expecting something like:

label1 [ text field 1 ]
label2 [ text field 2 ]

I'm guessing that in your application the Label is after the Text, is that correct? Like:

[ text field 1 ] label1
[ text field 2 ] label2

In that case you simply can't use textWithLabel() as currently implemented. Then I would suggest to find the Text by index with text(int).

Another possibility could be that the X in your ABCXYZ is the tab character \t. The WithLabel matcher uses the WithMnemonic matcher on the label, which truncates everything after the tab, so that it finds for example "Select All" in the menu item text "Select &All\tCtrl+A"...

Patrick
Re: bot().textWithLabel() does not found appropriated text field [message #1800991 is a reply to message #1800990] Thu, 10 January 2019 17:23 Go to previous message
Alex Gor is currently offline Alex GorFriend
Messages: 151
Registered: November 2014
Location: Russia
Senior Member
Actually I have the following picture

ABC TextFied
ABCXYZ TextField2

By the way I found the following approach
final SWTBot bot = GeneralMethods.getBot(this.searchShell);
			@SuppressWarnings("unchecked")
			final Matcher<Label> matcher = allOf(widgetOfType(Label.class), anyOf(withRegex("ABC$")));
			final Label label = bot.widget(matcher);
			final SWTBotLabel swtBotLabel  = new SWTBotLabel(label); 
			


This code finds corrsponded label. but I don't know to jump to next text field
Previous Topic:2018-12 Issues
Next Topic:How to decrease warning message such as Widget is not enabled
Goto Forum:
  


Current Time: Sat Jul 11 06:05:51 GMT 2020

Powered by FUDForum. Page generated in 0.01872 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top