I use Selenium Webdriver + Thucydides. When I try to use a checkbox (any state: isEnabled(), isDisplayed(), isSelected()), so an error will occur. I tried the different locators: by id, name, xpath. The checkbox is available in the page source. All other element on the page work correctly. I use DisplayedElementLocatorFactory.
My locators:
@FindBy(id = "remember")
// @FindBy(xpath = ".//*[@type='checkbox']")
// @FindBy(name = "_remember_me")
protected WebElement rememberMeCheckbox;
HTML-source of checkbox:
<label for="remember" class="remember"><div class="checker" id="uniform-remember"><span><input type="checkbox" value="1" name="_remember_me" id="remember" /></span></div>Remember me</label>
My function:
public void isLoginFormLoadedCorrectly()
{
String pageSource = driver.getPageSource();
System.out.println(pageSource);
String errorMessage = "";
if (!loginInput.isDisplayed())
errorMessage += "Username field is not displayed or not found\r\n";
if (!passwordInput.isDisplayed())
errorMessage += "Password field is not displayed or not found\r\n";
if (!submitButton.isDisplayed())
errorMessage += "Submit button is not displayed or not found\r\n";
if (!passwordRecoveryLink.isDisplayed())
errorMessage += "Password recovery link is not displayed or not found\r\n";
if (!rememberMeCheckbox.isDisplayed())
errorMessage += "Remember me check-box is not displayed or not found\r\n";
// if (rememberMeCheckbox.isSelected())
// errorMessage += "Remember me check-box is selected\r\n";
assertThat(errorMessage, errorMessage.equals(""), is(true));
}
Error: net.thucydides.core.webdriver.WebdriverAssertionError: org.openqa.selenium.NoSuchElementException: Timed out after 30 seconds. Unable to locate the element Caused by: org.openqa.selenium.NoSuchElementException: Timed out after 30 seconds. Unable to locate the element Caused by: org.openqa.selenium.NoSuchElementException: Element is not usable