I can't find this element using selenium java webdriver.
I have a before class method that loads the firefox driver and set the WebDriverWait. Then I have a test method to look for the elements with the code below.
It never finds the following element. Can someone help me in figuring out this issue?
//Click More Genres
<li class="moreGenres">
<span>More Genres</span>
</li>
The code:
Actions builder = new Actions(driver);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".moreGenres>span")));
WebElement moregenres = driver.findElement(By.cssSelector(".moreGenres>span"));
builder.moveToElement(moregenres).click(moregenres);
builder.perform();
or using:
//Click More Genres
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".moreGenres>span")));
WebElement moregenres = driver.findElement(By.cssSelector(".moreGenres>span"));
moregenres.click();
//Click More Genres
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//li[@class='moreGenres']")));
WebElement moregenres = driver.findElement(By.xpath("//li[@class='moreGenres']"));
moregenres.click();
or:
//Click More Genres
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//li[@class='moreGenres']/span")));
WebElement moregenres = driver.findElement(By.xpath("//li[@class='moreGenres']/span"));
moregenres.click();