8

Was just reading this question https://stackoverflow.com/questions/26882604/selenium-difference-between-webdriver-findelement-and-webelement-findelement trying to understand the scope of the webelements findelement().

I have a scenario were I am looking for a radio button on a form and sometimes it is throwing an exception that another element will receive the click. So, I'm creating an extension method to wait till the element is clickable.. By finding it, checking if its clickable, if not loop round and find it again.

What I am wanting to know is, will this method work as expected? Or because I am using the webelement.findelement() method it will always pickup the the old none clickable radio button?

With findelement searching within that elements scope, not too sure if it will always find old elements at the time i get the form or be aware of any elements that get added or removed from it?

Example Code:

var element = _driver.TryFindElementWait(MyElement);
var myChildElement = element.TryFindElementWait(ChildElement);

If the dom of the element changes whilst doing element.TryFindElementWait() will element be aware of the changes or will it still be looking for an element that may or may not exist in element?

1 Answer 1

1

If the dom of the element changes whilst doing element.TryFindElementWait() will element be aware of the changes or will it still be looking for an element that may or may not exist in element?

Selenium starts finding an element after finishing loading page, so I don't think "the dom of the element changes whilst doing element.TryFindElementWait()" is a valid case here.

If your site works like this, Selenium may look at the old HTML to find your child element (Selenium may catch the new HTML if your DOM changes super fast)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.