0

Very new to Katalon Studio and selenium. Trying to write an automated test using selenium webdriver to change the value of the slider on the webpage. I am failing to locate the element. Somehting is wrong with my findelement statement. Also once I locate the slider element successfully I don't know how to change the value of the slider. Can you help? or provide some quidance?

 <div class="bdr-slider"
   <span id="bdrText">bdr Amount</span>
   <input min="0" max="15" step"0.5" value="5" type="range">
 </div>


 WebElement Slider = driver.findElement(By.xpath("*[div(@class,'bdr-     slider')]")) 
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
sammy
  • 11
  • 1
    That is not valid XPath. Most XPath locations start with the `/` character and go from there. Maybe something like `//div[@class='bdr-slider']`? – SiKing Jan 30 '19 at 22:17

3 Answers3

0

Try this : WebElement Slider = driver.findElement(By.xpath("//div[@class='bdr-slider']"))

Anand Somani
  • 801
  • 1
  • 6
  • 15
0

I'm not familiar with specifics of mobile automation, but I think that you need to locate the input element. This one

<input min="0" max="15" step"0.5" value="5" type="range">

and then maybe call sendKeys method on that element. You can try this line of code:

driver.findElement(By.xpath("//div[@class='bdr-slider']/input")).sendKeys("10");
  • I tried your solution but I get this error message: org.openqa.selenium.NoSuchElementException: Unable to locate element: //div[@class='bdr-slider']/input – sammy Jan 31 '19 at 15:50
0

Before proceeding, make sure the element is really present in the DOM, and thus making sure the problem is not with the path, enter $x('//div[@class="bdr-slider"]/input') to console in DevTools and see if you can locate the element.

If you can find the element, since you are using Katalon Studio, you can do this:

TestObject slider = new TestObject().addProperty('css', ConditionType.EQUALS, '.bdr-slider input')

or, if you prefer xpath:

 TestObject slider = new TestObject().addProperty('xpath', ConditionType.EQUALS, "//div[@class='bdr-slider']/input")

You will need to import these two:

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77