From 7a47febb2fdb03a743cca60409426ff70cc463a2 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Mon, 31 Mar 2014 08:24:34 +0300 Subject: Refactored slider disable test. Change-Id: I800c66399f32ca671d41425b11bd059def1fa9c9 --- .../tests/components/slider/SliderDisableTest.java | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'uitest/src/com') diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java index 53521ee483..f8fed28fac 100644 --- a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java +++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java @@ -15,9 +15,14 @@ */ package com.vaadin.tests.components.slider; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + import java.io.IOException; import org.junit.Test; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; @@ -27,11 +32,33 @@ public class SliderDisableTest extends MultiBrowserTest { @Test public void disableSlider() throws IOException { openTestURL(); + + assertSliderHandlePositionIs(38); + + // Move slider handle from 38px to 150px + moveSlider(112); + + assertSliderHandlePositionIs(150); + driver.findElement(By.id("disableButton")).click(); + + assertSliderIsDisabled(); + assertSliderHandlePositionIs(150); + } + + private void assertSliderIsDisabled() { + WebElement slider = driver.findElement(By.className("v-slider")); + assertThat(slider.getAttribute("class"), containsString("v-disabled")); + } + + private void moveSlider(int offset) { WebElement element = vaadinElement("/VVerticalLayout[0]/Slot[0]/VSlider[0]/domChild[2]/domChild[0]"); - new Actions(driver).dragAndDropBy(element, 112, 0).perform(); + new Actions(driver).dragAndDropBy(element, offset, 0).perform(); testBench().waitForVaadin(); - compareScreen("enabled"); - vaadinElementById("disableButton").click(); - compareScreen("disabled"); + } + + private void assertSliderHandlePositionIs(int position) { + WebElement handle = driver.findElement(By.className("v-slider-handle")); + + assertThat(handle.getCssValue("margin-left"), is(position + "px")); } } \ No newline at end of file -- cgit v1.2.3