DropDown selection is showing ElementNotVisibleException. | Selenium Forum
M
Posted on 24/02/2016
I am tring to select one option from the dropdown box which has 211 items in to it, but the page is showing me the following error. It is in getSearchFilter function, option.sendKeys(Keys.ENTER); line.
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 10.10 seconds

public class DataScreen {

@FindBy(xpath=Constants.datascreen)
public WebElement Data;
@FindBy(id = Constants.DataSearch)
public WebElement btnSearch;
@FindBy(xpath = Constants.NetworkSearch)
public WebElement drpNetwork;
@FindBy(id = Constants.DropNetwork)
public WebElement FltNetwork;
@FindBy(xpath = Constants.DrpACS)
public WebElement drpACS;
@FindBy(xpath = Constants.SelNetwork)
public WebElement selNetwork;
@FindBy(xpath = Constants.DropTaxid)
public WebElement Taxid;
WebDriver driver;
public DataScreen(WebDriver dr){
driver = dr;
}

public void getDataScreen(){
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Data.click();
btnSearch.click();
drpNetwork.click();
System.out.println("done with the Data screen loading");

}

public void getSearchFilter(){

Select sel = new Select(FltNetwork);
List<WebElement> network = sel.getOptions();
System.out.println("Networks " + network.size());

for(WebElement option : network){
System.out.println(option.getAttribute("value"));
if(option.getAttribute("value").equals("HPO")){
System.out.println("It is now HPO");
selNetwork.click();
option.getAttribute("value").equals("HPO");
option.sendKeys(Keys.ENTER);

}
}



HTML code :
<div id="prepay-datascreen-searchparameters" class="col-xs-12">
<div id="prepay-datascreen-searchnetwork" class="row">
<div class="col-xs-6">
<div class="row" data-bind="with: searchParameters">
<div class="form-group col-xs-6">
<select id="prepay-datascreen-searchnetwork-network" class="form-control" data-bind="options: networks, optionsCaption: 'Network', value: selectedNetwork" data-placeholder="Network" tabindex="-1" style="display: none;">
<option value="">Network</option>
<option value="ACPN">ACPN</option>
<option value="ACPNWC">ACPNWC</option>
<option value="ACS">ACS</option>
<option value="ACS30">ACS30</option>
<option value="ADIN">ADIN</option>
<option value="Align">Align</option>
-----------------------------------------------------------

<span class="select2-search select2-search--dropdown">
<span class="select2-results">
<ul id="select2-prepay-datascreen-searchnetwork-network-results" class="select2-results__options" role="tree" aria-expanded="true" aria-hidden="false">
<li id="select2-prepay-datascreen-searchnetwork-network-result-69nq-ACPN" class="select2-results__option" role="treeitem" aria-selected="false">ACPN</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-6avx-ACPNWC" class="select2-results__option" role="treeitem" aria-selected="false">ACPNWC</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-fzvx-ACS" class="select2-results__option select2-results__option--highlighted" role="treeitem" aria-selected="false">ACS</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-v3x4-ACS30" class="select2-results__option" role="treeitem" aria-selected="false">ACS30</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-jesn-ADIN" class="select2-results__option" role="treeitem" aria-selected="false">ADIN</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-fwye-Align" class="select2-results__option" role="treeitem" aria-selected="false">Align</li>
<li id="select2-prepay-datascreen-searchnetwork-network-result-92qn-AmericanPPO" class="select2-results__option" role="treeitem" aria-selected="false">AmericanPPO</li>

M
Replied on 24/02/2016

add a wait statement.


M
Replied on 25/02/2016

Its not working with Wait statement.
if I do option,getText(); it is showing blank spaces for 211 times. and so I am getting ElementNotVisibleException.


M
Replied on 25/02/2016

when you open the website manually is element visible?


M
Replied on 25/02/2016

Yes.


M
Replied on 25/02/2016

attached the screen shot

Responsive image

M
Replied on 25/02/2016

you have to click to make the element visible right?


M
Replied on 29/02/2016

I tried the click event also

option.click();

But still not getting the item selected, is there any hidden code ?


M
Replied on 29/02/2016

try this

option.sendKeys("ACS");

//add a wait statement here
option.sendKeys(Keys.Return);


M
Replied on 29/02/2016

Tried with your given code also, it is not working. Showing Element Not Visible Exception.


M
Replied on 29/02/2016

ping me on skype.


M
Replied on 02/03/2016

Please tell me the solution if the Select method is hidden, how to click on any of the item ?
The code which you asked me to write is not working.


M
Replied on 02/03/2016

call me on skype. my skype id is qtpselenium1


M
Replied on 08/03/2016

Tried calling you on Skype, but not got any reply. Please tell me what time should I call you ?


M
Replied on 08/03/2016

11:00 AM (IST)