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:
I first tried to move the thumb by using the method SmartClientWebDriver.dragAndDrop. Here is the code I used:
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
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.
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);
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");
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);
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.
Comment