Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » KeyStrokes don't work anymore with Mac
KeyStrokes don't work anymore with Mac [message #1801499] Mon, 21 January 2019 10:03 Go to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi,
I have migrated my Eclipse plugins project to eclipse 2018-12, checked with latest swtbot 2.8 or 2.9 versions....

My testcase is:
@RunWith(SWTBotJunit4ClassRunner.class)
public class SmallUiTest  {

  @Test
  public void simpleTest() throws Exception {
    //Close the welcome dialog
    SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot();
    swtWorkbenchBot.viewByTitle("Welcome").close();

    //Try to open "Open resource" dialog with COMMAND-SHIFT-R, but doesn't open anything
    swtWorkbenchBot.activeShell().pressShortcut(SWT.COMMAND | SWT.SHIFT, 'R');
    SWTBotShell openResourceShell = swtWorkbenchBot.shell("Open Resource");
    System.out.println (openResourceShell.getText());
  }
}


and I expect the "Open resource" dialog to open, but this seems to fail

I am using macOs 10.14.2, jdk 1.8.0_191-b1.

Would be nice if you could give me a hint why this does not work anymore. This code worked with same version of swtbot but older eclipse (and perhaps older version of macos - don't know exactly anymore).

Thanks in advance
Cheers
Markus
Re: KeyStrokes don't work anymore with Mac [message #1801527 is a reply to message #1801499] Mon, 21 January 2019 18:58 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
Hi Markus,

I'm assuming it fails with a WidgetNotFoundException waiting for the "Open Resource" shell?

Lately I notice a lot of keyboard focus issues when using the keyboard with SWTBot. You are calling pressShortcut() on the active shell. Are you sure that the active shell is the Eclipse window? Sometimes the active shell can even be null. Or perhaps the focus control is not one for which the Open Resource command is enabled.

It might help to be specific about which control should have keyboard focus. You could try something like:

swtWorkbenchBot.shell("Project Explorer").bot().tree().pressShortcut(...)

Let us know if you figure out what the problem was.

Patrick
Re: KeyStrokes don't work anymore with Mac [message #1801556 is a reply to message #1801527] Tue, 22 January 2019 14:22 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Patrick,

thank you for your suggestion.
I tried to be more explicit with:
 SWTBotTree tree = swtWorkbenchBot.viewByPartName("Project Explorer").bot().tree();
    System.out.println ("Tree is active: " + tree.isActive() + "-" + tree);
    tree.setFocus();
    tree.pressShortcut(SWT.COMMAND | SWT.SHIFT, 'r');


but - also the tree is active - and I even set the focus the dialog is not being opened....
Re: KeyStrokes don't work anymore with Mac [message #1801564 is a reply to message #1801556] Tue, 22 January 2019 16:30 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
Hi Markus,

I think it needs to be 'R' not 'r'.

If it still fails, what is the log output?

Patrick
Re: KeyStrokes don't work anymore with Mac [message #1801595 is a reply to message #1801564] Wed, 23 January 2019 09:40 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Sorry, doesn't work, but I saw another thing, that could give us an hint from output, perhaps it's the bold warning, which leads to my problem:


Perspective: Resource
View: Project Explorer-Project Explorer
View: Outline-Outline
View: Tasks-Tasks
Shell: null-PartRenderingEngine's limbo-
Shell: null-junit-workspace - Eclipse Platform-
Shell: null-Quick Access-
Shell: null--
Project Explorer view: org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView@29929614
Tree is active: true
2019-01-23 10:37:01.172 java[89142:8195649] pid(89142)/euid(503) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

My testcase:


@RunWith(SWTBotJunit4ClassRunner.class)
public class SmallUiTest  {

  @Test
  public void simpleTest() throws Exception {
    //Close the welcome dialog
    SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot();
    swtWorkbenchBot.viewByTitle("Welcome").close();

    System.out.println ("Perspective: " + swtWorkbenchBot.activePerspective().getLabel());
    for (SWTBotView nextView: swtWorkbenchBot.views()) {
      System.out.println ("View: " + nextView.getTitle() + "-" + nextView.getReference().getPartName());
    }
    for (SWTBotShell nextShell: swtWorkbenchBot.shells()) {
      System.out.println ("Shell: " + nextShell.getId() + "-" + nextShell.getText() + "-" + nextShell.getToolTipText());
    }
    System.out.println ("Project Explorer view: " + swtWorkbenchBot.viewByPartName("Project Explorer"));
    
    //Try to open "Open resource" dialog with COMMAND-SHIFT-R, but doesn't open anything
    SWTBotTree tree = swtWorkbenchBot.viewByPartName("Project Explorer").bot().tree();
    System.out.println ("Tree is active: " + tree.isActive());
    tree.pressShortcut(SWT.COMMAND | SWT.SHIFT, 'R');
    Thread.sleep(10000);
  }
}

Re: KeyStrokes don't work anymore with Mac [message #1801622 is a reply to message #1801595] Wed, 23 January 2019 18:13 Go to previous message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
Hmm, that warning could be related, see this blog post: https://indiestack.com/2018/08/let-it-rip/ . Seems to be related to keyboard shortcuts...

Are you able to run in a debugger step-by-step to see when the warning occurs? It could be in a static initializer or constructor the first time you access SWTBot's keyboard classes...

Not sure if it would change anything, but also try:

tree.pressShortcut(Keystrokes.COMMAND, Keystrokes.SHIFT, KeyStroke.getInstance('R'));
Previous Topic:SWTBot and WebStart how to add test plugin to application
Next Topic:SWTBot now supports reading of Status Line messages
Goto Forum:
  


Current Time: Sat Apr 20 05:04:26 GMT 2024

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

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

Back to the top