I'm having issues clicking on a hidden button his the element in full?
<a class="score-button hidden-xs hidden-sm" data-ux-module="score_bootstrap/Components/Button" data-ux-state="loaded" href="https://testwebsite.com/corporate/careers/jobs">Search all jobs</a>
Here's my test albeit my latest version this time with an xpath which I'm never a massive fan of using anyway. But CSS selector didn't work either.
@And("the user clicks on Search all jobs")
public void the_user_clicks_on() {
WebDriverWait longWait = new WebDriverWait(driver, Duration.ofSeconds(20)); // Increase the wait time
WebElement submenuElement = longWait.until(ExpectedConditions.elementToBeClickable(
By.xpath("//a[contains(@class, 'score-button') and contains(@href, 'corporate/careers/jobs') and contains(text(), 'Search all jobs')]")));
submenuElement.click();
}
Error I receive:
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //a[contains(@class, 'score-button') and contains(@href, 'corporate/careers/jobs') and contains(text(), 'Search all jobs')] (tried for 20 second(s) with 500 milliseconds interval)
The Error is pretty clear it cant find the element but how can the element be found is it nested in to the sub menu?
Am I dealing with a hidden button here or what?
Whats the best and cleanest approach to just click this button?
waiting for element to be clickable, can you tryExpectedConditions.visibilityOfElementLocatedor thisExpectedConditions.presenceOfElementLocatedinstead ofelementToBeClickable? See if that makes any difference.