Community
Participate
Working Groups
In SWTWorkbenchBot class there is viewByTitle(String title) which is treated as a shortcut for view(withPartName(title)). In fact part's and it's title are two different things. There should be two methods viewByPartName(String partName) and viewByTitle(String title) where the second one is using a matcher that compares IWorkbenchPartReference#getTitle() not IWorkbenchPartReference#getPartName(). In my case partName and view title are two different things and there is no possiblility to check the former one.
That sounds like a good improvement/fix. Would you mind to turn this request into a code contribution? http://wiki.eclipse.org/SWTBot/Contributing#Provide_a_contribution_using_Gerrit
Oh, I just noticed this: https://git.eclipse.org/r/#/c/15264/ ;) It's generally a good think to add link to the Gerrit contribution in Bugzulla, so it can prevent readers with their heads in the cloud (like me) to add useless comments.
Thanks Mickael, I'll remember that in future. We're going to use SWTBots on Eclipse 4.3 so as soon as I find any other issue I'll try to investigate it and if possible provide some fix.
This change will be available in next SWTBot snapshot ( http://download.eclipse.org/technology/swtbot/snapshots ) when https://hudson.eclipse.org/hudson/view/SWTBot/job/swtbot-tycho/120/ is finished.
The merged change doesn't contain viewByPartName. The workaround is pretty small, but just thought I'd comment in case anyone is confused by the non-existent method.
@Roland: feel free to reopen the issue and add a Gerrit patch if you want to add a viewPartName. It'll be welcome.
Reopening, I'm gonna apply the proposal of Roland
The fix is pushed to gerrit: https://git.eclipse.org/r/#/c/15659/
Thanks Michal. This second patch was merged as well.
I'm not entirely sure if this is working as expected. The title isn't the actual title text visible in the view, but rather a combination of the part name and the content description. For a part name of 'foo' and content description of 'bar', the title is 'foo (bar)'. I would think viewByTitle should just get the content description since that's what the user sees as the 'title'. Either way, I wrote a sample to allow the testing of viewByTitle specifically in the case where it's value is not the same as the part name : http://rgrunber.fedorapeople.org/0001-WIP-Make-changes-to-test-viewByTitle.patch
@Roland: In my case it is working exactly the same as it is implemented now. I'll double check that and maybe I'll find the reason of such differences.
@Roland: Maybe you can turn your sample into a Unit test in org.eclipse.swtbot.eclipse.finder.test . That would help everyone to agree on the best implementation for these new methods.
Just as a note, I've been testing this with mvn clean install -Pkepler (from within org.eclipse.swtbot.eclipse.finder.test since the affected components would mainly be there) When no content description is set, the title is assigned the value of the part name. When I run the tests through maven, and doing a setContentDescription at the bottom of createPartControl in SWTBotTestView causes all the tests in SWTBotViewTest using viewByTitle to fail since the value of the title is $partname ($content_description). There's a sample test case in the patch and in particular contains : SWTBotView view = bot.viewByTitle("SWTBot Test View (Test View Title)"); where "SWTBot Test View" is the part name and "Test View Title" is the content description (the text shown just below the part name). That passes for me, and I'd be ok with that. The only way I've found to avoid this issue is by using setTitle but it's deprecated in favour of setContentDescription.
Thanks Roland, I'm gonna check the same on my project, and if it's also valid the solution is obvious and I'll change it to conform to this behavior.