gwt - A way to identify SmartGWT SelectItem in Selenium Grid 2 (WebDriver) tests -
i trying set id selectitem (to options list, more precisely) in order able identify during selenium grid 2 tests , find no way it. need find list , select (click) value on it.
tried , failed intents:
- the usual methods purpose
setid()
,ensuredebugid()
not available in selectitem - the method
setname()
don't leave trace in generated html it impossible find options list on form contains selectitem. selectitem consists of separate elements:
- label(title)
- textinput(selected value)
- picker(button display options drop-down list)
- picklist(the options drop-down list)
if set id form contains component in order localize through
classname
can't spot picklist, it's getting generated when picker clicked , generated code placed out of form bounds, can't find within form. possible find on whole document, in case of having more 1 lists there no way know list belongs selectitem.
any advice welcome. thank in advance.
update: clarify avoid misunderstandings: know there plenty different opinions different selenium tools , versions , best ways use smart gwt. question not entering these discussions. limited boundaries indicated in question title: selenium grid 2 tests webdriver.
some background: when coding our gwt components, identify of them (carefully, no duplications) setid()
method testing purposes, don't care these identifiers may read in resulting html. (using ensuredebugid()
distorted our view, reason. besides, isomorphic guys recommended forget it, anyway.) setid()
not available formitem
, i.e. not set id selectitem
(which extends formitem
) in order write test first not empty option selected.
what find selectitem
lets set picker icon name, never used and/or needed:
selectiteminstance.setpickericonname("somename");
this name later present in generated html. decided make use of , assign way id, in case of setid()
. webdriver
methods allow later find selectitem
element name following these steps:
1) find form (that has selectitem
element inside) id
2) find selectitem
elements inside form
formelement.findelements(by.classname("selectitemcontrol"));
3) select 1 has pickericonname equal id assigned setpickericonname()
(looping through found elements):
selectitemelement.findelement(by.xpath("//*[@*='" + pickericonnameid + "']"));
4) when found, click on options list generated
pickerelement.click();
note: options list generated not before first click on selectitem
element , stays on, changing visible invisible. when generated, out of boundaries of form contains corresponding selectitem
. may problem, because if have more 1 selectitem
elements in window (which likely), have find the correct options list. several criterias might applied find it. chose options list's location easiest , reliable one: options list "sticks" selectitem
element should right one.
5) find options lists on window:
driver.findelementsbyclassname("picklistmenubody")
6) choose right options list selectitem
: using getlocation()
, getsize()
methods of webelement
, check of options list found intersects/touches selectitem
element ("selectitemcontrol") found through steps 2 , 3
that's it, here on choose necessary item in "listtable" (contained inside options list element, i.e. "picklistmenubody"), did more once.
remember take loading time account when searching elements , keep utility/infrastructure code separated test code, otherwise become mess.
this not elegant solution, works , sure gwt , selenium teams, in time, offer better.
any comments , suggestions (limited use of selenium grid 2) welcome. thank you.