Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    can't move thumb on discrete slider with Selenium and scLocator

    I am using SmartGWT 4.1-p20140521.

    I’m writing Selenium tests on a SmartGWT application. I’m trying to change the value of a discrete slider.

    Using Firefox I found that the scLocator for the slider thumb is:

    scLocator=//Slider[ID='OptionDiscreteSlider']/thumb[Class=StatefulCanvas||index=0||length=1||classIndex=0||classLength=1]/

    I create the slider like this:

    Code:
    Slider slider = new Slider();
    slider.setID("OptionDiscreteSlider");
    setMaxValue((double) 5);
    slider.setMinValue((double) 0);
    slider.setVertical(false);
    slider.setShowValue(false);
    slider.setShowTitle(false);
    slider.setShowRange(false);
    slider.setNumValues(size);
    slider.setCanFocus(false);
    I first tried to move the thumb by using the method SmartClientWebDriver.dragAndDrop. Here is the code I used:

    Code:
    SmartClientWebDriver driver = getDriver();
    By thumb = ByScLocator.scLocator("scLocator=//Slider[ID='OptionDiscreteSlider']/thumb[Class=StatefulCanvas||index=0||length=1||classIndex=0||classLength=1]/");
    driver.waitForElementClickable(thumb);
    driver.dragAndDrop(thumb, "+92,+3");
    This code moves the thumb to the desired position and then shortly after that the thumb is moved to the start position of the slider. This happens no matter what distance I move the thumb using the dragAndDrop method. I tried several other drag and drop methods such as Actions.dragAndDropBy and WebElement.dragAndDropBy. The result was always the same. The thumb would move to the desired position and then shortly it would be moved the first position of the discrete slider.

    Next I tried using SmartClientWebDriver to click on a specific position on the discrete slider.

    Using Firefox I found the scLocator for the slider and a specific position on the slider as:

    scLocator=//Slider[ID="OptionDiscreteSlider"]/track[Class=StatefulCanvas||index=0||length=1||classIndex=0||classLength=1]/targetValue[3]

    Here is the code used to

    Code:
    SmartClientWebDriver driver = getDriver();
    By slider = ByScLocator.scLocator("scLocator=//Slider[ID='OptionDiscreteSlider']/track[Class=StatefulCanvas||index=0||length=1||classIndex=0||classLength=1]/targetValue[3]");
    driver.waitForElementClickable(slider);
    driver.click(slider);
    This code does move the thumb on the slider but it moves it to the middle position (position 2) instead of position 3. I vary targetValue with values from 0 to 5 but it always moves it to the middle position, position 2.

    Please let me know if there is a correct/different way to move the thumb on the slider using Selenium. Also, since this appears to be a bug, please let me know if it can be fixed.

    #2
    We don't see the behavior you describe in the latest SGWT LGPL 4.1p.

    Using a slider built thusly (modifying locally the SGWT Showcase sample):

    Code:
    Canvas canvas = new Canvas();
    
    int size = 6;
    Slider slider = new Slider();
    slider.setTop(100);
    slider.setLeft(100);
    slider.setID("OptionDiscreteSlider");
    slider.setMaxValue(5);
    slider.setMinValue(0);
    slider.setVertical(false);
    slider.setShowValue(false);
    slider.setShowTitle(false);
    slider.setShowRange(false);
    slider.setNumValues(size);
    slider.setCanFocus(false);
    
    canvas.addChild(slider);
    and the following standalone WebDriver code:

    Code:
    SmartClientWebDriver driver = new SmartClientFirefoxDriver();
    driver.setBaseUrl("http://localhost:8080/");
    driver.get("index.html#controls_category_slider");
    By thumb = ByScLocator.scLocator("scLocator=//Slider[ID='OptionDiscreteSlider']/thumb[Class=StatefulCanvas||index=0||length=1||classIndex=0||classLength=1]/");
    driver.waitForElementClickable(thumb);
    Thread.sleep(3000); // just so I can see it run; not required
    driver.dragAndDrop(thumb, "+92,+3");
    The value moves to 3 from 1 (the default) and stays there. We don't see it pop back. (The delay is present just so we can see it move - otherwise by the time the window opens, it's already there. But it doesn't jump back in that case either - it works fine.)

    You'll need to submit a complete repro case for the behavior you describe so we can see it happen:
    - the entire repro SGWT java code file, such as a tweaked SGWT Showcase sample
    - the entire repro WebDriver java file, including import lines
    Last edited by Isomorphic; 26 May 2014, 11:01.

    Comment

    Working...
    X