Я пытаюсь выбрать опцию в DropDown, используя селен Java. Я также попробовал много решений. Элемент страны обнаружен при выполнении XPath в FirePath, но не найден во время выполнения сценария.
Селен код:
driver.findElement(By.xpath("//*[@class='selectize-input items not-full has-options']")).click();
Thread.sleep(500);
String countryXpath = "//*[@class='select-item']/following::span[text()='India']";
System.out.println(countryXpath);
WebElement countryName = driver.findElement(By.xpath(countryXpath));
ScrollHelper.ScrollHorizontalUpToVisibilityOfElement(countryName);
countryName.click();
HTML код:
<select class="selectized isfocused parsley-error" name="Country" data-input-parsley="" data-parsley-trigger="change input" data-parsley-required-message="This field should not empty" data-parsley-required="true" data-parsley-group="country-select" tabindex="-1" style="display: none;" data-parsley-id="17">
<option value="" selected="selected"/>
</select>
<div class="selectize-control single">
<div class="selectize-input items has-options not-full focus input-active dropdown-active">
<input autocomplete="off" tabindex="" style="width: 100%; opacity: 1; position: relative; left: 0px;" placeholder="" type="text"/>
</div>
<div class="selectize-dropdown single" style="display: block; visibility: visible; width: 413px; top: 32px; left: 0px;">
<div class="selectize-dropdown-content">
<div class="select-item" data-selectable="" data-value="6">
<div class="select-option">
<span class="text"> Australia </span>
</div>
</div>
<div class="select-item" data-selectable="" data-value="2">
<div class="select-option">
<span class="text"> Canada </span>
</div>
</div>
<div class="select-item" data-selectable="" data-value="21">
<div class="select-option">
<span class="text"> China </span>
</div>
</div>
<div class="select-item" data-selectable="" data-value="22">
<div class="select-option">
<span class="text"> India </span>
</div>
</div>
<div class="select-item" data-selectable="" data-value="25">
<div class="select-option">
<span class="text"> USA </span>
</div>
</div>
</div>
![enter image description here](https://i.stack.imgur.com/WDqHn.png)