0

Please see this:

IWebDriver driver;
WebDriverWait WebDriverWait;

public IWebElement Button
{
    return new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla")));
}

Now in case I want to search some IWebElement but instead of driver.FindElement I want to use another IWebElement I can do the following:

IWebElement webElement..
IWebElement webElement e = webElement.FindElement(By.XPath("my selector"));

So in this case I want to use WebDriverWait to instead of just webElement.FindElement.

Is it possible ?

1 Answer 1

2

WebDriverWait.Until() returns IWebElement, you can assign the returned value to a variable or just concat another method

IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla")));
element.FindElement((By.XPath("my selector"));

Is the same as

new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla"))).FindElement(By.XPath("my selector"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.