Skip to main content



      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 09:56 Go to next message
Eclipse UserFriend
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 12:12 Go to previous messageGo to next message
Eclipse UserFriend
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 12:23 Go to previous message
Eclipse UserFriend
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: Mon May 12 21:38:03 EDT 2025

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

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

Back to the top