Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to Click on a Label using swtbot ??
How to Click on a Label using swtbot ?? [message #1427005] Fri, 19 September 2014 14:58 Go to next message
pawan garia is currently offline pawan gariaFriend
Messages: 39
Registered: February 2013
Member
Hi All ,

I have a Date Picker in which the no's are as Label and to select a date i have click on the Date i want to select.

I am not Able to select that label using swtbot, i tried following code but nothing is happening.

final Label DateButton3 = (Label) bot.widget(WidgetMatcherFactory.withText(" 20 "));
final Control control = (Control) DateButton3;
control.getDisplay().syncExec(new Runnable(){
@Override
public void run() {
System.out.println("lab "+DateButton3.getText());
Event event = new Event();
event.type = SWT.MouseDoubleClick;
control.getDisplay().post(event);
}
});

Date picker in eclipse Spy is :

Location:
//Shell/-1//Shell/-1//Shell/-1//DateTimePicker/0//Composite/2//Label/28

Layout Information:
Label { 20 }
Style: NO_FOCUS | CENTER | LEFT_TO_RIGHT
Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Bounds: Rectangle {185, 52, 30, 15}


Children: 0

Siblings: 50
Label {Sun}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Mon}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Tue}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Wed}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Thu}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Fri}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {Sat}: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label {}: Layout Data: GridData {horizontalAlignment=SWT.FILL horizontalSpan=7 grabExcessHorizontalSpace=true verticalAlignment=SWT.BEGINNING}
Label { 31 }: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Label { 1 }: Layout Data: GridData {horizontalAlignment=SWT.FILL grabExcessHorizontalSpace=true verticalAlignment=SWT.TOP grabExcessVerticalSpace=true}
Labe

index.php/fa/19192/0/
  • Attachment: Untitled.png
    (Size: 11.87KB, Downloaded 175 times)
Re: How to Click on a Label using swtbot ?? [message #1430658 is a reply to message #1427005] Wed, 24 September 2014 16:11 Go to previous messageGo to next message
Mickael Istria - away until August 14th is currently offline Mickael Istria - away until August 14thFriend
Messages: 833
Registered: July 2009
Location: Grenoble, France
Senior Member

What's wrong with bot.label(" 20 ").click() ?

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: How to Click on a Label using swtbot ?? [message #1431096 is a reply to message #1430658] Thu, 25 September 2014 07:41 Go to previous messageGo to next message
pawan garia is currently offline pawan gariaFriend
Messages: 39
Registered: February 2013
Member
Hi

SWTBotLabel class does not have a click method.

due to that i can not use the
bot.label(" 20 ").click()

is there a way to do that ?????
Please suggest me something because of that we are stuck.
Thanks
Re: How to Click on a Label using swtbot ?? [message #1431177 is a reply to message #1431096] Thu, 25 September 2014 09:57 Go to previous messageGo to next message
pawan garia is currently offline pawan gariaFriend
Messages: 39
Registered: February 2013
Member
Ok i found My Solution :

i have created a class which extends AbstractSWTBotControl<Control> class.

and created the click() method which overload the click()
public AbstractSWTBot<Control> click()
{
return super.click(true);
}


in my testing class, i use like

Label DateButton1 = (Label) bot.widget(WidgetMatcherFactory.withText(" 20 "));
SWTBotLabel dateButtonFound1 = new SWTBotLabel(DateButton1, null);
SwtBotLabelClick buttonlabel = new SwtBotLabelClick(DateButton1);
buttonlabel.click();

Re: How to Click on a Label using swtbot ?? [message #1433725 is a reply to message #1431177] Mon, 29 September 2014 07:12 Go to previous message
Mickael Istria - away until August 14th is currently offline Mickael Istria - away until August 14thFriend
Messages: 833
Registered: July 2009
Location: Grenoble, France
Senior Member

I believe your solution is a good one.
It would be nice if you could contribute addition of the click method on
any control directly to SWTBot: http://wiki.eclipse.org/SWTBot/Contributing

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Previous Topic:SWTBotRadio method click() doesn't work properly
Next Topic:Cannot use ClickContextMenu on a extended SWTBot widget
Goto Forum:
  


Current Time: Thu Nov 15 14:44:22 GMT 2018

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

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

Back to the top