diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/matcher/BrowserListsElementMatcher.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/matcher/BrowserListsElementMatcher.java index 1e4f848854f76ca3981e1824101d9e2cbf863ad4..cc6bb662fddb9f9b73cd35211343b0a114159419 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/matcher/BrowserListsElementMatcher.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/matcher/BrowserListsElementMatcher.java @@ -26,8 +26,8 @@ import ch.systemsx.cisd.openbis.uitest.infra.Row; /** * @author anttil */ -public class BrowserListsElementMatcher<T extends Browsable, U extends Browser<T>> extends - TypeSafeMatcher<U> +public class BrowserListsElementMatcher<T extends Browsable, U extends Browser<T>> + extends TypeSafeMatcher<U> { private T expected; diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Action.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Action.java new file mode 100644 index 0000000000000000000000000000000000000000..4799dab1a2512c77545e0f11f1527400095342b3 --- /dev/null +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Action.java @@ -0,0 +1,25 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.uitest.infra.webdriver; + +/** + * @author anttil + */ +public interface Action +{ + public void execute(); +} diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Refreshing.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Refreshing.java index 369103f9652c4d29a604f1d476ed5a76d77b1eb5..7876b72cdaadc8d4ec6c53b18492356db24df01f 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Refreshing.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/Refreshing.java @@ -21,5 +21,5 @@ package ch.systemsx.cisd.openbis.uitest.infra.webdriver; */ public interface Refreshing { - public boolean hasRefreshed(); + public String getState(); } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java index 5ebe8131da41243c1e77699b1bf02fe106cc744b..0ca199555459f0cdbb3d88055fcde5cd39602ae3 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/infra/webdriver/WaitForRefreshOf.java @@ -28,21 +28,34 @@ import com.google.common.base.Predicate; public class WaitForRefreshOf extends FluentWait<Refreshing> { + private final String state; + + private Action action; + public WaitForRefreshOf(Refreshing widget) { super(widget); + this.state = widget.getState(); + } + + @SuppressWarnings("hiding") + public WaitForRefreshOf after(Action action) + { + this.action = action; + return this; } public void withTimeoutOf(int seconds) { - this.withTimeout(seconds, TimeUnit.SECONDS) + action.execute(); + withTimeout(seconds, TimeUnit.SECONDS) .pollingEvery(100, TimeUnit.MILLISECONDS) .until(new Predicate<Refreshing>() { @Override public boolean apply(Refreshing widget) { - return widget.hasRefreshed(); + return !state.equals(widget.getState()); } }); } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/AssignSamplePropertyType.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/AssignSamplePropertyType.java index 4daf95aff296b3af0979c490cf0e17bbbd34262e..97acb322e5121a3acad1c3e91ce9cb5cedc1a062 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/AssignSamplePropertyType.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/AssignSamplePropertyType.java @@ -19,11 +19,10 @@ package ch.systemsx.cisd.openbis.uitest.page.tab; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; import ch.systemsx.cisd.openbis.uitest.type.PropertyTypeAssignment; -import ch.systemsx.cisd.openbis.uitest.type.PropertyTypeDataType; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.Checkbox; import ch.systemsx.cisd.openbis.uitest.widget.DropDown; -import ch.systemsx.cisd.openbis.uitest.widget.Text; +import ch.systemsx.cisd.openbis.uitest.widget.Fillable; import ch.systemsx.cisd.openbis.uitest.widget.Widget; public class AssignSamplePropertyType @@ -53,25 +52,7 @@ public class AssignSamplePropertyType if (assignment.getInitialValue() != null && assignment.getInitialValue().length() > 0) { - PropertyTypeDataType type = assignment.getPropertyType().getDataType(); - - if (type.equals(PropertyTypeDataType.BOOLEAN)) - { - initialValue.handleAs(Checkbox.class).set( - assignment.getInitialValue().equals("true")); - } else if (type.equals(PropertyTypeDataType.VARCHAR)) - { - initialValue.handleAs(Text.class).write(assignment.getInitialValue()); - } else if (type.equals(PropertyTypeDataType.INTEGER)) - { - initialValue.handleAs(Text.class).write(assignment.getInitialValue()); - } else if (type.equals(PropertyTypeDataType.CONTROLLED_VOCABULARY)) - { - initialValue.handleAs(DropDown.class).select(assignment.getInitialValue()); - } else - { - throw new IllegalArgumentException("Type " + type + " not supported"); - } + ((Fillable) initialValue).fillWith(assignment.getInitialValue()); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java index a9fa491a79e7e10a34374055facec5d6700bf8c5..10706daf4af57c91f99a01bd92edd09f67732fbb 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ExperimentTypeBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.ExperimentType; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -70,11 +69,10 @@ public class ExperimentTypeBrowser implements Browser<ExperimentType> } @Override - public void filter(ExperimentType type) + public void filter(final ExperimentType type) { paging.filters(); - filters.setCode(type.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(type.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java index b64deb40ac1a2d5be486211810080f38bec38c28..35640b15f509ebba2f22d61c0626f1eb14d1bd59 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/ProjectBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.Project; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -61,8 +60,7 @@ public class ProjectBrowser implements Browser<Project> public void filter(Project project) { paging.filters(); - filters.setCode(project.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(project.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java index aea639ab12923a4f912af55db959c7468bcb2a23..109c00ba938adafe8d80eae2a2ba7929ed727b41 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeAssignmentBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.PropertyTypeAssignment; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -64,8 +63,7 @@ public class PropertyTypeAssignmentBrowser implements Browser<PropertyTypeAssign public void filter(PropertyTypeAssignment assignment) { paging.filters(); - filters.setCode(assignment.getPropertyType().getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(assignment.getPropertyType().getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java index d9138986c35bb09d92d39546c74ec7a5cc03c124..26f48af9b2bf2c3bd035a04c98729bbb1b10e70e 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/PropertyTypeBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.PropertyType; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -65,8 +64,7 @@ public class PropertyTypeBrowser implements Browser<PropertyType> public void filter(PropertyType propertyType) { paging.filters(); - filters.setCode(propertyType.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(propertyType.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/RegisterSample.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/RegisterSample.java index be678aa3e05b09e3a082ef974c24875d638fefd7..fae6edc569218c575627e6655cac65e3fa3923d1 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/RegisterSample.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/RegisterSample.java @@ -23,15 +23,13 @@ import java.util.Map; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; import ch.systemsx.cisd.openbis.uitest.type.PropertyType; -import ch.systemsx.cisd.openbis.uitest.type.PropertyTypeDataType; import ch.systemsx.cisd.openbis.uitest.type.Sample; import ch.systemsx.cisd.openbis.uitest.type.SampleType; import ch.systemsx.cisd.openbis.uitest.widget.Button; -import ch.systemsx.cisd.openbis.uitest.widget.Checkbox; import ch.systemsx.cisd.openbis.uitest.widget.DropDown; +import ch.systemsx.cisd.openbis.uitest.widget.Fillable; import ch.systemsx.cisd.openbis.uitest.widget.Form; import ch.systemsx.cisd.openbis.uitest.widget.Text; -import ch.systemsx.cisd.openbis.uitest.widget.Widget; public class RegisterSample { @@ -69,27 +67,9 @@ public class RegisterSample for (PropertyType propertyType : properties.keySet()) { - Widget w = form.getWidget(propertyType.getLabel()); - PropertyTypeDataType type = propertyType.getDataType(); - String value = properties.get(propertyType).toString(); - - switch (type) - { - case BOOLEAN: - w.handleAs(Checkbox.class).fillWith(value); - break; - case VARCHAR: - w.handleAs(Text.class).fillWith(value); - break; - case INTEGER: - w.handleAs(Text.class).fillWith(value); - break; - case CONTROLLED_VOCABULARY: - w.handleAs(DropDown.class).fillWith(value); - break; - default: - throw new IllegalArgumentException(type + " not supported"); - } + Fillable widget = (Fillable) form.getWidget(propertyType); + widget.fillWith(properties.get(propertyType).toString()); + } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java index 6d1ff1271805c84903996685e61d89de2d3359e1..946ee796480c955ee747fd2501a801be35b13974 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleBrowser.java @@ -23,7 +23,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.Sample; import ch.systemsx.cisd.openbis.uitest.type.SampleType; import ch.systemsx.cisd.openbis.uitest.widget.Button; @@ -90,8 +89,7 @@ public class SampleBrowser implements Browser<Sample> public void filter(Sample sample) { paging.filters(); - filters.setCode(sample.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(sample.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java index 1f36c16e274fbea2d3bf5a78e4ab427941646817..36180029c24ca8fb82a5fce251d7dd39511bed6d 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SampleTypeBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.SampleType; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -77,8 +76,7 @@ public class SampleTypeBrowser implements Browser<SampleType> public void filter(SampleType type) { paging.filters(); - filters.setCode(type.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(type.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java index 2040e2cab2822b72dea7af103261c1149fe319b3..190b7aa55cc2eed36757e0b4b6a2b8ee6fa74fa9 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/SpaceBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.Space; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.DeletionConfirmationBox; @@ -76,11 +75,10 @@ public class SpaceBrowser implements Browser<Space> } @Override - public void filter(Space space) + public void filter(final Space space) { paging.filters(); - filters.setCode(space.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(space.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java index 98997c80516a47c8f1f62cbed2e0729f9e92f9c7..a62a11d95c57c91cb1c3277d8e00c4e37397c515 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/page/tab/VocabularyBrowser.java @@ -21,7 +21,6 @@ import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Lazy; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Locate; -import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; import ch.systemsx.cisd.openbis.uitest.type.Vocabulary; import ch.systemsx.cisd.openbis.uitest.widget.Button; import ch.systemsx.cisd.openbis.uitest.widget.FilterToolBar; @@ -68,8 +67,7 @@ public class VocabularyBrowser implements Browser<Vocabulary> public void filter(Vocabulary vocabulary) { paging.filters(); - filters.setCode(vocabulary.getCode()); - new WaitForRefreshOf(grid).withTimeoutOf(10); + filters.setCode(vocabulary.getCode(), grid); } @Override diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/PropertyTypeDataType.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/PropertyTypeDataType.java index 2f61aeb1042473a740f8099f69c426fb03c2e258..0af09b6c2bf8be6fcf34f64aa1cf3ab35c4ec12b 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/PropertyTypeDataType.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/PropertyTypeDataType.java @@ -16,31 +16,54 @@ package ch.systemsx.cisd.openbis.uitest.type; +import ch.systemsx.cisd.openbis.uitest.widget.Checkbox; +import ch.systemsx.cisd.openbis.uitest.widget.DropDown; +import ch.systemsx.cisd.openbis.uitest.widget.Text; +import ch.systemsx.cisd.openbis.uitest.widget.TextArea; +import ch.systemsx.cisd.openbis.uitest.widget.Widget; + /** * @author anttil */ -public enum PropertyTypeDataType +public enum PropertyTypeDataType { - BOOLEAN("BOOLEAN"), - HYPERLINK("HYPERLINK"), - INTEGER("INTEGER"), - MATERIAL("MATERIAL"), - MULTILINE_VARCHAR("MULTILINE_VARCHAR"), - REAL("REAL"), - TIMESTAMP("TIMESTAMP"), - VARCHAR("VARCHAR"), - XML("XML"), - CONTROLLED_VOCABULARY("CONTROLLEDVOCABULARY"); + BOOLEAN("BOOLEAN", Checkbox.class), + HYPERLINK("HYPERLINK", Text.class), + INTEGER("INTEGER", Text.class), + MATERIAL("MATERIAL", Text.class), + MULTILINE_VARCHAR("MULTILINE_VARCHAR", TextArea.class), + REAL("REAL", Text.class), + TIMESTAMP("TIMESTAMP", Text.class), + VARCHAR("VARCHAR", Text.class), + XML("XML", TextArea.class), + CONTROLLED_VOCABULARY("CONTROLLEDVOCABULARY", DropDown.class); private String name; - private PropertyTypeDataType(String name) + private Class<? extends Widget> widgetClass; + + private PropertyTypeDataType(String name, Class<? extends Widget> widgetClass) { this.name = name; + this.widgetClass = widgetClass; } public String getName() { return this.name; } + + public Widget representedAs() + { + try + { + return widgetClass.newInstance(); + } catch (InstantiationException ex) + { + throw new RuntimeException(ex); + } catch (IllegalAccessException ex) + { + throw new RuntimeException(ex); + } + } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/Representable.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/Representable.java new file mode 100644 index 0000000000000000000000000000000000000000..2ccf348d20a15b69431f0fbb2904a26767e8c809 --- /dev/null +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/type/Representable.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.uitest.type; + +import ch.systemsx.cisd.openbis.uitest.widget.Fillable; +import ch.systemsx.cisd.openbis.uitest.widget.Widget; + +/** + * @author anttil + */ +public interface Representable<T extends Widget & Fillable> +{ + public T representedAs(); +} diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/AlertMessageBox.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/AlertMessageBox.java index a16ba6cc6d4775b3b7d599fb4c39a3a0720488fb..98f971d490dd73fbd0ab240094e5e6c5b050514d 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/AlertMessageBox.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/AlertMessageBox.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.openbis.uitest.widget; -import org.openqa.selenium.WebElement; /** * @author anttil @@ -25,7 +24,7 @@ public class AlertMessageBox extends Widget { public void dismiss() { - WebElement ok = find(".//button[text()=\"OK\"]"); + Button ok = find(".//button[text()=\"OK\"]").handleAs(Button.class); ok.click(); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Button.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Button.java index cfdb31783bee3efa001d28902aecac2290272e6c..32e776acd77daa5300daf76f3babc150bf1e544c 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Button.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Button.java @@ -36,7 +36,7 @@ public class Button extends Widget button = context; } else { - button = find(".//button"); + button = find(".//button").getContext(); } return "true".equalsIgnoreCase(button.getAttribute("aria-pressed")); } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Checkbox.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Checkbox.java index 6afa0d7fb58a33af467cd1d8768a55b5859cea9d..e2c25b8b05d25f0eae902b327a97687b22b3eb84 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Checkbox.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Checkbox.java @@ -25,7 +25,7 @@ public class Checkbox extends Widget implements Fillable { public void set(boolean value) { - WebElement input = find("input"); + WebElement input = find("input").getContext(); if (input.getAttribute("checked") != null ^ value) { input.click(); diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DeletionConfirmationBox.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DeletionConfirmationBox.java index ba600da29f579d861d7d342b773b2f32c57e5720..043a9a48daa4908e084b36c55655759da39a6506 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DeletionConfirmationBox.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DeletionConfirmationBox.java @@ -16,8 +16,6 @@ package ch.systemsx.cisd.openbis.uitest.widget; -import org.openqa.selenium.WebElement; - /** * @author anttil */ @@ -25,17 +23,19 @@ public class DeletionConfirmationBox extends Widget { public void confirm(String reason) { + TextArea text = find(".//textarea").handleAs(TextArea.class); + text.write(reason); - WebElement text = find(".//textarea"); - text.sendKeys(reason); - - WebElement ok = find(".//button[text()=\"OK\"]"); - ok.click(); + getOkButton().click(); } public void confirm() { - WebElement ok = find(".//button[text()=\"OK\"]"); - ok.click(); + getOkButton().click(); + } + + private Button getOkButton() + { + return find(".//button[text()=\"OK\"]").handleAs(Button.class); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DropDown.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DropDown.java index 3df548affcbd821e0db3e18873c2e29c70455d15..8bed7177f2677393337e4c5f3ffb8ae5d2c90d74 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DropDown.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/DropDown.java @@ -60,7 +60,7 @@ public class DropDown extends Widget implements Fillable private List<WebElement> getChoiceElements() { - WebElement opener = find(".//img"); + WebElement opener = find(".//img").getContext(); opener.click(); return SeleniumTest.driver.findElements(By.className("x-combo-list-item")); } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java index 2c1611ba0a82756f2c841f1b3cb0abc94431257a..799de2351137690d89f0a1db428a9d5c0e5969e7 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/FilterToolBar.java @@ -16,23 +16,33 @@ package ch.systemsx.cisd.openbis.uitest.widget; +import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Action; +import ch.systemsx.cisd.openbis.uitest.infra.webdriver.WaitForRefreshOf; + /** * @author anttil */ public class FilterToolBar extends Widget { - public void setCode(String text) + public void setCode(final String text, Grid refreshingGrid) { - Text t = new Text(); - t.setContext(find(".//input[contains(@id, 'Code-input')]")); - t.write(text); + final Text t = find(".//input[contains(@id, 'Code-input')]").handleAs(Text.class); + + new WaitForRefreshOf(refreshingGrid).after(new Action() + { + @Override + public void execute() + { + t.write(text); + } + }).withTimeoutOf(10); + } public void reset() { - Button b = new Button(); - b.setContext(find(".//button[text()='Reset']")); + Button b = find(".//button[text()='Reset']").handleAs(Button.class); b.click(); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Form.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Form.java index da9bd363b0714e8694326e34d33c92fc2dd8c6c3..a555229a209fc2d320a1c7e6eae9db24308eecfc 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Form.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Form.java @@ -22,27 +22,27 @@ import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import ch.systemsx.cisd.openbis.uitest.type.PropertyType; + /** * @author anttil */ public class Form extends Widget { - public Widget getWidget(String label) + public Widget getWidget(PropertyType type) { List<WebElement> elements = findAll(".//form/div/label"); for (WebElement element : elements) { - if (element.getText().toLowerCase().startsWith(label.toLowerCase())) + if (element.getText().toLowerCase().startsWith(type.getLabel().toLowerCase())) { - Widget w = new Widget() - { - }; + Widget w = type.getDataType().representedAs(); w.setContext(element.findElement(By.xpath("../div/div"))); return w; } } - throw new IllegalArgumentException("Could not find " + label); + throw new IllegalArgumentException("Could not find " + type.getLabel()); } public List<String> getLabels() diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java index 5209e75cbd4458b5b9a562a3744f2280f8a403b3..3b5ea166c691bbef0b723c1818bd77d89f48360b 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Grid.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.uitest.widget; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -26,6 +27,7 @@ import org.openqa.selenium.WebElement; import ch.systemsx.cisd.openbis.uitest.infra.Cell; import ch.systemsx.cisd.openbis.uitest.infra.Row; import ch.systemsx.cisd.openbis.uitest.infra.webdriver.Refreshing; +import ch.systemsx.cisd.openbis.uitest.suite.SeleniumTest; /** * @author anttil @@ -93,7 +95,15 @@ public class Grid extends Widget implements Refreshing private List<WebElement> getCells() { - return findAll(".//td[not(ancestor::div[contains(@style,'display:none')]) and contains(@class, 'x-grid') and contains(@class, '-col ')]//*[not(*)]"); + SeleniumTest.driver.manage().timeouts().implicitlyWait(500, TimeUnit.MILLISECONDS); + try + { + return findAll(".//td[not(ancestor::div[contains(@style,'display:none')]) and contains(@class, 'x-grid') and contains(@class, '-col ')]//*[not(*)]"); + } finally + { + SeleniumTest.driver.manage().timeouts().implicitlyWait(SeleniumTest.IMPLICIT_WAIT, + TimeUnit.SECONDS); + } } @Override @@ -120,29 +130,9 @@ public class Grid extends Widget implements Refreshing return s; } - boolean itsOn = false; - - int last = 0; - @Override - public synchronized boolean hasRefreshed() + public synchronized String getState() { - if (itsOn) - { - if (this.last != getCells().size()) - { - this.itsOn = false; - return true; - } else - { - return false; - } - } else - { - itsOn = true; - this.last = getCells().size(); - return false; - } - + return "" + this.getCells().size(); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java index 58ad8aa7591058293a5aee4025b7f3730688ce77..c5f767137196e76a4f8df37d237cfea5093035f9 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/PagingToolBar.java @@ -16,7 +16,6 @@ package ch.systemsx.cisd.openbis.uitest.widget; -import org.openqa.selenium.WebElement; /** * @author anttil @@ -26,9 +25,7 @@ public class PagingToolBar extends Widget public void filters() { - WebElement button = find(".//button[text()='Filters']"); - Button b = new Button(); - b.setContext(button); + Button b = find(".//button[text()='Filters']").handleAs(Button.class); if (!b.isPressed()) { b.click(); diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Text.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Text.java index 7656326fae6119dbbf17210e394d9fdd552c0517..c27cbd56a6f45724558961435a14741ca27a51d3 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Text.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Text.java @@ -47,7 +47,7 @@ public class Text extends Widget implements Fillable return context; } else { - return find("input"); + return find("input").getContext(); } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/TextArea.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/TextArea.java index 1e1b84394a5f6f086d5ef859ea00e582c86de742..e4cc7a41e11d42f7f91abeffff383bc582a33648 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/TextArea.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/TextArea.java @@ -25,21 +25,19 @@ public class TextArea extends Widget implements Fillable { public void write(String text) { - WebElement element = find(".//textarea"); + WebElement element = getElement(); element.clear(); element.sendKeys(text); } public void clear() { - WebElement element = find(".//textarea"); - element.clear(); + getElement().clear(); } public void append(String text) { - WebElement element = find(".//textarea"); - element.sendKeys(text); + getElement().sendKeys(text); } @Override @@ -47,4 +45,15 @@ public class TextArea extends Widget implements Fillable { write(string); } + + private WebElement getElement() + { + if (context.getTagName().equals("textarea")) + { + return context; + } else + { + return find(".//textarea").getContext(); + } + } } diff --git a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Widget.java b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Widget.java index 5e0992453a1324d222dbaf340bfe0515f63e8d59..8abaeaa3f211e65c5eeb0454adc060525bc37608 100644 --- a/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Widget.java +++ b/ui-test/source/java/ch/systemsx/cisd/openbis/uitest/widget/Widget.java @@ -38,9 +38,13 @@ public abstract class Widget return context; } - protected WebElement find(String xpath) + protected Widget find(String xpath) { - return context.findElement(By.xpath(xpath)); + Widget w = new Widget() + { + }; + w.setContext(context.findElement(By.xpath(xpath))); + return w; } protected List<WebElement> findAll(String xpath)