0

I am trying to select a field (checkbox), however I am not able to, using code below:

WebElement comboboxElement = driver.findElement(By.xpath("//*[@id=\"chkRANGE_0_2K\"]"));
        comboboxElement.click();

I've also tried this:

WebElement comboboxElement = driver.findElement(By.id("chkRANGE_2K_5K"));
driver.findElement(By.xpath("//*[@id=\"chkRANGE_2K_5K\"]")).click();

Select combobox = new Select(comboboxElement);    
dropdown.selectByValue("RANGE_0_2K");

HTML:

<input type="checkbox" value="RANGE_0_2K" id="chkRANGE_0_2K" class="ng-untouched ng-pristine ng-valid xh-highlight">
  • What is the error you're getting? – demouser123 Oct 7 '17 at 3:53
1

From the above html provided, It is clear that the input tag is of type='checkbox'.

And you are trying to perform actions related to a select tag (like selectByValue) on an input tag of type checkbox.

Actions that can be performed on an checkbox are click() etc..

0

It is a checkbox how you are able to select it, Select class is used to select value from drop down

Use this code to click on checkbox

WebElement ele= driver.findElement(By.id("chkRANGE_0_2K"));
ele.click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.