selenide: $.getWrappedElement() should not wait for timeout if element does not exist
the subj method is implemented based on the command:
public class ToWebElement implements Command<WebElement> {
@Override
public WebElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
return locator.getWebElement();
}
}
this command will fail if element does not exist… and will be retried inside “the only one logic of SelenideElementProxy invocation of all commands”:
class SelenideElementProxy implements InvocationHandler {
//...
@Override
public Object invoke(Object proxy, Method method, Object... args) throws Throwable {
if (methodsToSkipLogging.contains(method.getName()))
return Commands.getInstance().execute(proxy, webElementSource, method.getName(), args);
validateAssertionMode(config());
long timeoutMs = getTimeoutMs(method, args);
long pollingIntervalMs = getPollingIntervalMs(method, args);
SelenideLog log = SelenideLogger.beginStep(webElementSource.getSearchCriteria(), method.getName(), args);
try {
Object result = dispatchAndRetry(timeoutMs, pollingIntervalMs, proxy, method, args);
SelenideLogger.commitStep(log, PASS);
return result;
}
catch (Error error) {
Error wrappedError = UIAssertionError.wrap(driver(), error, timeoutMs);
SelenideLogger.commitStep(log, wrappedError);
if (config().assertionMode() == SOFT && methodsForSoftAssertion.contains(method.getName()))
return proxy;
else
throw wrappedError;
}
catch (RuntimeException error) {
SelenideLogger.commitStep(log, error);
throw error;
}
}
// ...
}
but it should not… We should have a raw interface to original Selenium WebDriver WebElement without any waiting logic…
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
Commits related to this issue
- #1015 add test (just in case): $.toWebElement() should not wait for timeout if element does not exist — committed to selenide/selenide by asolntsev 4 years ago
- #1015 $.getWrappedElement() should not wait for timeout if element does not exist — committed to selenide/selenide by asolntsev 4 years ago
- #1015 add javadoc — committed to selenide/selenide by asolntsev 4 years ago
- #1015 $.getWrappedElement() should not wait for timeout if element do… (#1124) * #1015 $.getWrappedElement() should not wait for timeout if element does not exist — committed to selenide/selenide by asolntsev 4 years ago
- #1191 $.getWrappedElement waits again for the element this reverts commit 2836814d45b09, issue #1015 and PR #1124 — committed to selenide/selenide by asolntsev 4 years ago
- #1191 $.getWrappedElement waits again for the element (#1203) this reverts commit 2836814d45b09, issue #1015 and PR #1124 — committed to selenide/selenide by asolntsev 4 years ago
I suggest that both methods should NOT wait. They are rather synonyms. Otherwise it’s too hard to keep the difference in mind.
I don’t see any reasons why someone would need the “waiting” here.