Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Generating test id for components not created programmatically(During testing RAP 2.3 with Selenium it came into the place where I should generate test-ids for menu elements)
Generating test id for components not created programmatically [message #1494478] Mon, 01 December 2014 14:03 Go to next message
Gábor Lipták is currently offline Gábor LiptákFriend
Messages: 21
Registered: July 2009
Junior Member
Could you give me any hint how I could generate test-ids for menu elements in RAP? The menu elements are defined in plugin.xml and for this reason the test-id assignment described at http://eclipsesource.com/blogs/2014/04/29/how-to-write-ui-tests-for-rap-with-selenium-2-0/ don't work for them. Any ideas are welcome.
Re: Generating test id for components not created programmatically [message #1494503 is a reply to message #1494478] Mon, 01 December 2014 14:30 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2339
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
if you are using RAP 2.3 you could try this approach [1]. Please note
that PhaseListeners are already removed in RAP 3.0 (were deprecated in
RAP 2.3). We are looking for replacement.

[1] https://gist.github.com/ralfstx/5791804
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Generating test id for components not created programmatically [message #1494574 is a reply to message #1494503] Mon, 01 December 2014 15:36 Go to previous messageGo to next message
Gábor Lipták is currently offline Gábor LiptákFriend
Messages: 21
Registered: July 2009
Junior Member
I managed to get a point where I can attach my custom HTML attribute. I attach an IWindowListener inside our WorkbenchAdvisor.postStartup method. Then I use something like this:

@Override
public void windowOpened(IWorkbenchWindow window) {
	if ( window instanceof ApplicationWindow ) {
		ApplicationWindow applicationWindow = (ApplicationWindow) window;
		MenuManager menuManager = applicationWindow.getMenuBarManager();
		for (IContributionItem item : menuManager.getItems()) {
			if (item instanceof MenuManager) {
				defineTestIdsForMenuManager((MenuManager) item);
			} 
		}
	}
}

public void defineTestIdsForMenuManager( MenuManager item ) {
	if ( item.getMenu() != null ) {			
		System.out.println( "Menu with id " + item.getId() + " gets id " + WidgetUtil.getId(item.getMenu()) );
		UITestUtil.setTestId(item.getMenu(), item.getId());
	}
	for (IContributionItem child : item.getItems() ) {
		if ( child instanceof MenuManager ) {
			defineTestIdsForMenuManager((MenuManager) child);
		}
	}
}


The problem is that the HTML attribute does not show up in the HTML element. Any idea why?

[Updated on: Mon, 01 December 2014 15:37]

Report message to a moderator

Re: Generating test id for components not created programmatically [message #1494619 is a reply to message #1494574] Mon, 01 December 2014 16:16 Go to previous message
Gábor Lipták is currently offline Gábor LiptákFriend
Messages: 21
Registered: July 2009
Junior Member
Got it. So works:

UITestUtil.setTestId(menuManager.getMenu().getParentItem(), menuManager.getId());

So the attribute must be added to the menu.getParentItem().

Works, great.
Previous Topic:Change Label Image when pressed
Next Topic:[Combo] Text Highlighting after SelectionChange by a Function
Goto Forum:
  


Current Time: Sat May 30 09:31:21 GMT 2020

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

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

Back to the top