When I click a button to open a drop-down menu, I am attempting to select specific elements in webdriver. The button clicks fine and the dropdown pops down successfully.
WebElement providers = driver.findElement(By.id("providers"));
providers.click();
The HTML code is as follows:
<input id="providers" class="providersOff" type="button">
<div id="providers-list" class="">
<ul>
<li ng-click="searchProvider(0)">
<div class="imageContainer">
<span>Google</span> <--TRYING TO SELECT THIS
I am specifically trying to select the Google
element within the list.
I have attempted the following selectors without success:
driver.findElement(By.cssSelector(".imageContainer[Google]"));
driver.findElement(By.cssSelector(".providers-list > li[ng-click*= searchProvider(0)]"));
However, the following commands run perfectly:
// Assign search-bar & send keys
WebElement searchbar = driver.findElement(By.id("txtSearch"));
searchbar.sendKeys("Pizza");
// Assign provider drop-down & click
WebElement providers = driver.findElement(By.id("providers"));
providers.click();