Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Help to Click on SWT Element
Help to Click on SWT Element [message #1230385] Sat, 11 January 2014 21:39 Go to next message
Miguel Pessoa is currently offline Miguel PessoaFriend
Messages: 22
Registered: May 2012
Location: Brazil
Junior Member
Hello, I have a problem to run a test with SWTBot and I need some help.

I need to fill in two fields using SWTBot, but when I run the application it fills the first "Name (*)" and "Attibutes (*)" is inserted overlapping the "Name (*)" field, the field is "Attibutes" never being completed.

How do I solve this problem? This interface is attached.
Thank you for your cooperation.

PS: Sorry for my english, I'm still learning.


bot.comboBox("select observer type").setSelection(type);
bot.button("New").click();
		
bot.waitUntil(Conditions.shellIsActive("TerraME GIMS :: Observer TextScreen"));
SWTBotShell shell = bot.shell("TerraME GIMS :: Observer TextScreen");
shell.activate();
		
bot.textWithLabel("Name (*)").setText(observer);
bot.textWithLabel("Attibutes (*)").setText(attributes);
  • Attachment: interface.JPG
    (Size: 42.21KB, Downloaded 260 times)
Re: Help to Click on SWT Element [message #1230898 is a reply to message #1230385] Mon, 13 January 2014 10:44 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 01/11/2014 10:39 PM, Miguel Pessoa wrote:
> I need to fill in two fields using SWTBot, but when I run the application it fills the first "Name (*)" and "Attibutes (*)" is inserted overlapping the "Name (*)" field, the field is "Attibutes" never being completed.

As far as I can understand, it could be a bug in SWTBot finder. If you
think so, you should report it to the tracker, and ideally create and
contribute a TestCase which reproduces the failing scenario.
http://wiki.eclipse.org/SWTBot/Contributing#Getting_the_source
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Help to Click on SWT Element [message #1231518 is a reply to message #1230898] Tue, 14 January 2014 21:37 Go to previous messageGo to next message
Miguel Pessoa is currently offline Miguel PessoaFriend
Messages: 22
Registered: May 2012
Location: Brazil
Junior Member
Thank you for your answer Mickael Istria. I'll report this problem.

I tried using the TAB key to jump to the next textline and then to set text. But the bot is still entering the item above.
Is there any alternative method that you can use to make it work?

This not work :/
bot.textWithLabel("Name (*)").setText(observer);
bot.sleep(1000);
Keyboard key = KeyboardFactory.getSWTKeyboard();
KeyStroke tab = KeyStroke.getInstance(SWT.TAB, 0);
key.pressShortcut(tab);
bot.text().setText(attributes);

Re: Help to Click on SWT Element [message #1231749 is a reply to message #1231518] Wed, 15 January 2014 09:50 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 01/14/2014 10:37 PM, Miguel Pessoa wrote:
> bot.text().setText(attributes);

at this point bot.text() will run widget finder and return the first
text in widget (Name). SWTBot finder methods don't take focus into account.


--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Help to Click on SWT Element [message #1232682 is a reply to message #1231749] Fri, 17 January 2014 13:38 Go to previous messageGo to next message
Miguel Pessoa is currently offline Miguel PessoaFriend
Messages: 22
Registered: May 2012
Location: Brazil
Junior Member
Mickael Istria, you know how I can retrieve the widget that has the focus? Or how do I print on screen all the widgets available on the active sheel?
I'm looking for some alternative to make my test work.

Thanks Smile
Re: Help to Click on SWT Element [message #1232697 is a reply to message #1232682] Fri, 17 January 2014 14:20 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 01/17/2014 02:38 PM, Miguel Pessoa wrote:
> Mickael Istria, you know how I can retrieve the widget that has the
> focus? Or how do I print on screen all the widgets available on the
> active sheel? I'm looking for some alternative to make my test work.

As far as I remember, I don't think SWTBot has a method to retrieve the
widget that has the focus. That said once text has the focus, you can
directly simulate key pressed with SWTBot API to put text in it.
About alternative methods, you might be able to try bot.text(1) or
bot.text(1) (
http://git.eclipse.org/c/swtbot/org.eclipse.swtbot.git/tree/org.eclipse.swtbot.swt.finder/src/org/eclipse/swtbot/swt/finder/SWTBot.java#n1472
) or another method allowing to find text.
IMO, textWithLabel should work here. If it does not, it could be a bug
in SWTBot, that you should report to the tracker:
https://wiki.eclipse.org/SWTBot/Contributing#Report_a_bug_or_suggest_an_enhancement

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Help to Click on SWT Element [message #1232745 is a reply to message #1232697] Fri, 17 January 2014 16:09 Go to previous messageGo to next message
Miguel Pessoa is currently offline Miguel PessoaFriend
Messages: 22
Registered: May 2012
Location: Brazil
Junior Member
Hello, again thank you so much for your answer.
I try "bot.text(1)" and it works for me. Smile \o/

I'm relieved now Smile

Re: Help to Click on SWT Element [message #1232781 is a reply to message #1232745] Fri, 17 January 2014 18:15 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 01/17/2014 05:09 PM, Miguel Pessoa wrote:
> Hello, again thank you so much for your answer. I try "bot.text(1)" and
> it works for me. :) \o/

Cool. Can you please report your issue about textWithLabel to the tracker?
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Help to Click on SWT Element [message #1233531 is a reply to message #1232781] Sun, 19 January 2014 23:01 Go to previous message
Miguel Pessoa is currently offline Miguel PessoaFriend
Messages: 22
Registered: May 2012
Location: Brazil
Junior Member
Ok, I'll do it Smile
Previous Topic:Load saved workspace preferences at SWTBot test launch
Next Topic:SWTBot 2.2.0 release
Goto Forum:
  


Current Time: Tue Mar 19 10:16:00 GMT 2024

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

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

Back to the top