Thanks Jacob,

Our current project is not so complicated. However later this year we'll 
use GWT to build a more sophisticated project. Tables and cells are on of 
the most common object in a web page. Your approach makes the test code 
independent of the actual source of the app. However I was thinking to 
expose the needed table/composite attributes, e.g. column numbers header 
titles, so that I can reference them and make the test source dynamic.


Thanks for your answer ;)

On Wednesday, March 13, 2013 9:30:08 PM UTC+2, jacob....@gmail.com wrote:
>
> Plamen,
>
> What we ended up doing was wrapping the cell table elements in a <div>, 
> setting the ID in the same way as we would have called .ensureDebugId(). 
> This is possible by overriding the Column's onRender method in the 
> following way:
> final Column<T, Boolean> checkColumn = new Column<T, Boolean>(cell) {
> @Override
> public void render(Context context, T object, SafeHtmlBuilder sb) {
> if (**isWebsiteRunningAsDebug**)) {
> // Need to put something in here so that Selenium can dynamically find 
> roles by ID.
> sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + 
> T.getDebugId() + "\">");
> }
> super.render(context, object, sb);
> }
> };
>
> This method works for every type of Cell except for CheckCell, because the 
> GWT implementation finds the <input> element by calling getFirstChild(). 
> This can be overcome by overriding CheckCell.onBrowserEvent and changing 
> the line to:
> InputElement input = 
> parent.getElementsByTagName("input").getItem(0).cast();
>
> I'm not exactly happy with the way it turned out, as this creates a lot of 
> boilerplate any time we want to make CellTables testable, but short of 
> making subclasses of every Column, there isn't really another option.
>
> On Wednesday, March 13, 2013 12:27:19 PM UTC-4, Plamen Veselinov wrote:
>>
>> Hello Jacob,
>>
>> I am facing the same issue here. I want to use the source easy testing 
>> via WebDriver.
>> I share the same opinion as yours.
>> Did you manage to find a solution yet?
>>
>> On Friday, January 25, 2013 4:56:37 PM UTC+2, jacob....@gmail.com wrote:
>>>
>>> Unfortunately that isn't a real possibility with the way our project is 
>>> setup. What we ultimately need to do is something along the lines of "Find 
>>> the first column in the table at the row where the second column has the 
>>> text ______". If the cell and/or column elements could use the UIObjects 
>>> debugId stuff, that would be very easy as the cell's have access to the 
>>> actual object that is put into the row.
>>>
>>> Performance isn't the real issue; it's the fact that writing unit tests 
>>> that are completely dependent on aspects of the table that can be very 
>>> easily changed (such as CSS class, visible text, column ordering, etc.) is 
>>> not a path that w want to take. What we have been doing to find UiObjects 
>>> around the site is calling widget.ensureDebugId() using constant strings, 
>>> or if the content is dynamic, some sort of knowable addressing scheme (such 
>>> as formname-username). Unfortunately, there isn't any way to do this on 
>>> cell or column elements.
>>>
>>> On Friday, January 25, 2013 9:14:53 AM UTC-5, Lukasz Plotnicki wrote:
>>>>
>>>> What about using XPath and combining different attributes,e.g 
>>>>
>>>> driver.findElement(By.xpath("//div[contains(@class,'menuTitle') and 
>>>> contains(.,'Register Menu')]"))
>>>>
>>>>  We are using it and are quite happy as it is panel/layout-structure 
>>>> independent. The performance is not as good as with By.id, but acceptable.
>>>>  
>>>>
>>>> Am Donnerstag, 24. Januar 2013 15:16:08 UTC+1 schrieb 
>>>> jacob....@gmail.com:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I'm trying to setup Selenium unit testing for my project, and I'm 
>>>>> wondering if there is any equivalent to UiObject.ensureDebugId() for 
>>>>> elements in a CellTable, such as Column, Header, or any of the various 
>>>>> Cell 
>>>>> types. What I have been doing is override the Column.render() method to 
>>>>> dynamically insert a div with an ID that I can find later, but this seems 
>>>>> very hacky and counter-intuitive. I can't seem to find any way to do this 
>>>>> for the Header element though.
>>>>>
>>>>> Using xpath to find elements in the table is not an option, as our 
>>>>> unit tests can't be tied to the structure of the GUI staying exactly the 
>>>>> same. For the same reasons, trying to find elements by text or tag name 
>>>>> (etc. etc.) wouldn't work either.
>>>>>
>>>>> Is there something I'm missing here, or do the CellTable elements not 
>>>>> provide this functionality?
>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to