3
respostas

ExpectedConditions is deprecated

Código de exemplo:

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("q")));

Porém é exibido um warning em que o ExpectedConditions está deprecated.

Gosataria de saber o que substituiu o ExpectedConditions.

Versão Visual Studio: 15.8.1

Versão Selenium: 3.14.0

3 respostas

Oi Ketlin, não sou especialista em c#. Mas geralmente na documentação das classes, o que ta marcado com Deprecated já vem com a sugestão de alteração.

Então, neste caso não está sendo apresentado uma sugestão.

Clicando em Ctrl (+) . o Visual Studio apenas adiciona um comentário no código dizendo que está Deprecated , o que estou achando estranho, esperava também uma indicação.

Olá, Ketlin

No lugar de ExpectedConditions, agora você tem que usar textToBePresentInElement. Dê uma olhada neste documento:

https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#textToBePresentInElementLocated-org.openqa.selenium.By-java.lang.String-

textToBePresentInElement
@Deprecated
public static ExpectedCondition<java.lang.Boolean> textToBePresentInElement(By locator,
                                                                                        java.lang.String text)
Deprecated. Use textToBePresentInElementLocated(By, String) instead
An expectation for checking if the given text is present in the element that matches the given locator.
Parameters:
locator - used to find the element
text - to be present in the element found by the locator
Returns:
the WebElement once it is located and visible

Por favor, faça a substituição e veja se funciona.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software