Hi,
I am trying to implement Selenium Webdriver using Java.
Basically, I have a website with a button. Once user click that button, a small section below the button will be loaded (using AJAX).
That loaded section contains a blank field. Once user click on the field, a drop-down list with 5 options will appear and user should choose one option.
The HTML codes look like this
<!-- language: lang-html -->
<div class="default-form w-border scheduleAddFrom" style="display: block;">
<div>
<div class="section frameless nopadding nomargin" data-form-element="SectionHeading" style="min-width: 100%;">
<div class="section-body frameless nopadding nomargin">
<div class="default-form">
<div class="form-row required-message hidden" style="min-height: 25px;">
<div class="form-row print-avoid-page-break" data-form-element="FieldEdit" style="min-height: 25px;">
<label for="">Department</label>
<input id="Schedule-00-Row136153aa-9fa8-499b-8458-2b155443223bE-TaskId-Display" class="ui-autocomplete-display validate widget" type="text" autocomplete="off">
<span class="ui-autocomplete-display-icon"></span>
<div class="subhidden">
<select id="Schedule-00-Row136153aa-9fa8-499b-8458-2b155443223bE-TaskId" class="validate widget " data-default-value="" tabindex="5000" data-display-id="Schedule-00-Row136153aa-9fa8-499b-8458-2b155443223bE-TaskId-Display">
<option value=""></option>
<option value="OPT1">Option 1</option>
<option value="OPT2">Option 2</option>
<option value="OPT3">Option 3</option>
<option value="OPT4">Option 4</option>
<option value="OPT5">Option 5</option>
</select>
WebDriverWait wait = new WebDriverWait(driver, 100);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".form-row.print-avoid-page-break>label")));
//Start to find the element. The ID is dynamically randomly generated by the system each time the page loads except the last part TaskID, thus looking for the string TaskID
Select dropdown = new Select (driver.findElement(By.xpath(".//*[contains(@id,'TaskId')]")));
dropdown.selectByValue("OPT2");
org.openqa.selenium.ElementNotVisibleException: element not visible: Element is not currently visible and may not be manipulated
JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.querySelector(\"select[id*='TaskId']>option[value='OPT2']\").click();");
<div class="subhidden">
, but I am not too sure. Any suggestion is highly appreciated. Thanks.