-4

The error is that the dropdown value wasn't selected

WebElement dropDownListBox = driver.findElement(By.xpath("/html/body/div[4]/div[3]/div/ui-view/div/div[2]/div/div[7]/tahaluf-select/div/div[1]/div/a/span[3]/b"));
dropDownListBox.click();
Select clickThis = new Select(dropDownListBox);
clickThis.selectByVisibleText("INDIA");
Guy
  • 46,488
  • 10
  • 44
  • 88

1 Answers1

-1

There is two questions.
1. The first is how to select required element. You can combine the locator selection by attributes and by hierarchical dom position. If you need practical examples to understand use cases there it is.

<span ng-show="$select.isEmpty()" class="select2-chosen ng-binding">Please Select</span>

If there is no other elements with same classname the answer for your case for select the element can be the next two (would find the same element)

Select dropdown = new Select(driver.findElement(By.className("select2-chosen ng-binding")));
or
Select dropdown = new Select(driver.findElement(By.xpath("//span[@class='select2-chosen ng-binding']")));


2. The next step is to select the one of the options in dropdown. For example, like @Hien Nguyen linked below, it would be

dropdown.selectByVisibleText("there is a text from option you need to select")
or the next lane to select the first option in dropdown
dropdown.selectByIndex(0)

  • You can't use `Select` for any elements other than a `SELECT` HTML tag. For #2, OP's existing code clearly shows the use of `.selectByVisibleText()` so why reference that? Also, please don't combine quote formatting (>) with code formatting (`)... it makes it really hard to read. – JeffC Feb 07 '19 at 15:56
  • didnt select dropdown getting issue – krishna kulkarni Feb 08 '19 at 05:44
  • invalid selector: Compound class names not permitted (Session info: chrome=71.0.3578.98) (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 6.1.7600 x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z' – krishna kulkarni Feb 08 '19 at 05:45
  • plz ans this question – krishna kulkarni Feb 12 '19 at 06:08